java.util.LinkedHashSet.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中java.util.LinkedHashSet.<init>()方法的一些代码示例,展示了LinkedHashSet.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedHashSet.<init>()方法的具体详情如下:
包路径:java.util.LinkedHashSet
类名称:LinkedHashSet
方法名:<init>

LinkedHashSet.<init>介绍

[英]Constructs a new empty instance of LinkedHashSet.
[中]构造LinkedHashSet的新空实例。

代码示例

代码示例来源:origin: google/guava

@Override
 public Iterable<E> order(List<E> insertionOrder) {
  return gen.order(new ArrayList<E>(new LinkedHashSet<E>(insertionOrder)));
 }
}

代码示例来源:origin: square/retrofit

/**
 * Gets the set of unique path parameters used in the given URI. If a parameter is used twice
 * in the URI, it will only show up once in the set.
 */
static Set<String> parsePathParameters(String path) {
 Matcher m = PARAM_URL_REGEX.matcher(path);
 Set<String> patterns = new LinkedHashSet<>();
 while (m.find()) {
  patterns.add(m.group(1));
 }
 return patterns;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Update the exposed {@link #cacheNames} set with the given name.
 * <p>This will always be called within a full {@link #cacheMap} lock
 * and effectively behaves like a {@code CopyOnWriteArraySet} with
 * preserved order but exposed as an unmodifiable reference.
 * @param name the name of the cache to be added
 */
private void updateCacheNames(String name) {
  Set<String> cacheNames = new LinkedHashSet<>(this.cacheNames.size() + 1);
  cacheNames.addAll(this.cacheNames);
  cacheNames.add(name);
  this.cacheNames = Collections.unmodifiableSet(cacheNames);
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
 protected Class<? extends Attribute>[] computeValue(Class<?> clazz) {
  final Set<Class<? extends Attribute>> intfSet = new LinkedHashSet<>();
  // find all interfaces that this attribute instance implements
  // and that extend the Attribute interface
  do {
   for (Class<?> curInterface : clazz.getInterfaces()) {
    if (curInterface != Attribute.class && Attribute.class.isAssignableFrom(curInterface)) {
     intfSet.add(curInterface.asSubclass(Attribute.class));
    }
   }
   clazz = clazz.getSuperclass();
  } while (clazz != null);
  @SuppressWarnings({"unchecked", "rawtypes"}) final Class<? extends Attribute>[] a =
    intfSet.toArray(new Class[intfSet.size()]);
  return a;
 }
};

代码示例来源:origin: wildfly/wildfly

public String[] getMechanismNames(final Map<String, ?> props) {
    synchronized (loader) {
      final Set<String> set = new LinkedHashSet<>();
      final Iterator<SaslClientFactory> iterator = loader.iterator();
      SaslClientFactory clientFactory;
      for (;;) try {
        // Service loader iterators can blow up in various ways; that's why the loop is structured this way
        if (! iterator.hasNext()) {
          break;
        }
        clientFactory = iterator.next();
        // let SaslException bubble up
        Collections.addAll(set, clientFactory.getMechanismNames(props));
      } catch (ServiceConfigurationError ignored) {}
      return set.toArray(new String[set.size()]);
    }
  }
}

代码示例来源:origin: hankcs/HanLP

@Override
public Set<String> keySet()
{
  HashSet<String> stringSet = mdag.getAllStrings();
  LinkedHashSet<String> keySet = new LinkedHashSet<String>();
  Iterator<String> iterator = stringSet.iterator();
  while (iterator.hasNext())
  {
    String key = iterator.next();
    keySet.add(key.substring(0, key.length() - 3));
  }
  return keySet;
}

代码示例来源:origin: sohutv/cachecloud

@Override
@SuppressWarnings("unchecked")
public Set<Tuple> build(Object data) {
 if (null == data) {
  return null;
 }
 List<byte[]> l = (List<byte[]>) data;
 final Set<Tuple> result = new LinkedHashSet<Tuple>(l.size());
 Iterator<byte[]> iterator = l.iterator();
 while (iterator.hasNext()) {
  result.add(new Tuple(iterator.next(), Double.valueOf(SafeEncoder.encode(iterator.next()))));
 }
 return result;
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public List<String> resolveFileExtensions(MediaType mediaType) {
  Set<String> result = new LinkedHashSet<>();
  for (MediaTypeFileExtensionResolver resolver : this.resolvers) {
    result.addAll(resolver.resolveFileExtensions(mediaType));
  }
  return new ArrayList<>(result);
}

代码示例来源:origin: ReactiveX/RxJava

Set<Throwable> deDupedExceptions = new LinkedHashSet<Throwable>();
List<Throwable> localExceptions = new ArrayList<Throwable>();
if (errors != null) {
  for (Throwable ex : errors) {
    } else
    if (ex != null) {
      deDupedExceptions.add(ex);
    } else {
      deDupedExceptions.add(new NullPointerException("Throwable was null!"));
  deDupedExceptions.add(new NullPointerException("errors was null"));

代码示例来源:origin: apache/incubator-dubbo

private Set<String> resolvePackagesToScan(Set<String> packagesToScan) {
  Set<String> resolvedPackagesToScan = new LinkedHashSet<String>(packagesToScan.size());
  for (String packageToScan : packagesToScan) {
    if (StringUtils.hasText(packageToScan)) {
      String resolvedPackageToScan = environment.resolvePlaceholders(packageToScan.trim());
      resolvedPackagesToScan.add(resolvedPackageToScan);
    }
  }
  return resolvedPackagesToScan;
}

代码示例来源:origin: spotbugs/spotbugs

public static void main(String[] args) {
    Set<Integer> set = new LinkedHashSet<Integer>();
    List<Integer> list = new ArrayList<Integer>();

    for (int i = -3; i < 3; i++) {
      set.add(i);
      list.add(i);
    }
    for (int i = 0; i < 3; i++) {
      set.remove(i);
      list.remove(i);
    }
    System.out.println(set + " " + list);
  }
}

代码示例来源:origin: stackoverflow.com

Set<Integer> linkedHashSet = new LinkedHashSet<>();
linkedHashSet.add(3);
linkedHashSet.add(1);
linkedHashSet.add(2);
for (int i : linkedHashSet) {
  System.out.println(i);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Compare columns created from meta-data with declared columns and return a reconciled list.
 * @param declaredColumns declared column names
 * @param generatedKeyNames names of generated key columns
 */
protected List<String> reconcileColumnsToUse(List<String> declaredColumns, String[] generatedKeyNames) {
  if (generatedKeyNames.length > 0) {
    this.generatedKeyColumnsUsed = true;
  }
  if (!declaredColumns.isEmpty()) {
    return new ArrayList<>(declaredColumns);
  }
  Set<String> keys = new LinkedHashSet<>(generatedKeyNames.length);
  for (String key : generatedKeyNames) {
    keys.add(key.toUpperCase());
  }
  List<String> columns = new ArrayList<>();
  for (TableParameterMetaData meta : obtainMetaDataProvider().getTableParameterMetaData()) {
    if (!keys.contains(meta.getParameterName().toUpperCase())) {
      columns.add(meta.getParameterName());
    }
  }
  return columns;
}

代码示例来源:origin: line/armeria

private static SerializationFormat[] newAllowedSerializationFormats(
    SerializationFormat defaultSerializationFormat,
    Iterable<SerializationFormat> otherAllowedSerializationFormats) {
  requireNonNull(defaultSerializationFormat, "defaultSerializationFormat");
  requireNonNull(otherAllowedSerializationFormats, "otherAllowedSerializationFormats");
  final Set<SerializationFormat> set = new LinkedHashSet<>();
  set.add(defaultSerializationFormat);
  Iterables.addAll(set, otherAllowedSerializationFormats);
  return set.toArray(EMPTY_FORMATS);
}

代码示例来源:origin: spotbugs/spotbugs

referencedClassSet = new LinkedHashSet<>(referencedClassSet);
  referencedClassSet.removeAll(badClasses);
for (Iterator<AnalysisPass> passIterator = executionPlan.passIterator(); passIterator.hasNext();) {
  AnalysisPass pass = passIterator.next();
    System.out.println("Analysis order:");
    for (ClassDescriptor c : classCollection) {
      System.out.println("  " + c);
        && !classScreener.matches(classDescriptor.toResourceName())) {
      if (DEBUG) {
        System.out.println("*** Excluded by class screener");

代码示例来源:origin: google/guava

@Override
 TypeVariable<?> captureAsTypeVariable(Type[] upperBounds) {
  Set<Type> combined = new LinkedHashSet<>(asList(upperBounds));
  // Since this is an artifically generated type variable, we don't bother checking
  // subtyping between declared type bound and actual type bound. So it's possible that we
  // may generate something like <capture#1-of ? extends Foo&SubFoo>.
  // Checking subtype between declared and actual type bounds
  // adds recursive isSubtypeOf() call and feels complicated.
  // There is no contract one way or another as long as isSubtypeOf() works as expected.
  combined.addAll(asList(typeParam.getBounds()));
  if (combined.size() > 1) { // Object is implicit and only useful if it's the only bound.
   combined.remove(Object.class);
  }
  return super.captureAsTypeVariable(combined.toArray(new Type[0]));
 }
};

代码示例来源:origin: spring-projects/spring-framework

DependencyDescriptor desc = new DependencyDescriptor(field, this.required);
desc.setContainingClass(bean.getClass());
Set<String> autowiredBeanNames = new LinkedHashSet<>(1);
Assert.state(beanFactory != null, "No BeanFactory available");
TypeConverter typeConverter = beanFactory.getTypeConverter();
      this.cachedFieldValue = desc;
      registerDependentBeans(beanName, autowiredBeanNames);
      if (autowiredBeanNames.size() == 1) {
        String autowiredBeanName = autowiredBeanNames.iterator().next();
        if (beanFactory.containsBean(autowiredBeanName) &&
            beanFactory.isTypeMatch(autowiredBeanName, field.getType())) {

代码示例来源:origin: stackoverflow.com

public String deDup(String s) {
  return new LinkedHashSet<String>(Arrays.asList(s.split("-"))).toString().replaceAll("(^\\[|\\]$)", "").replace(", ", "-");
}

public static void main(String[] args) {
  System.out.println(deDup("Bangalore-Chennai-NewYork-Bangalore-Chennai"));
}

代码示例来源:origin: redisson/redisson

/**
 * Resolves all interfaces of a type. No duplicates are returned.
 * Direct interfaces are prior the interfaces of subclasses in
 * the returned array.
 */
public static Class[] resolveAllInterfaces(Class type) {
  Set<Class> bag = new LinkedHashSet<>();
  _resolveAllInterfaces(type, bag);
  return bag.toArray(new Class[bag.size()]);
}

代码示例来源:origin: spring-projects/spring-security-oauth

protected void setScope(Collection<String> scope) {
  if (scope != null && scope.size() == 1) {
    String value = scope.iterator().next();
    /*
     * This is really an error, but it can catch out unsuspecting users
     * and it's easy to fix. It happens when an AuthorizationRequest
     * gets bound accidentally from request parameters using
     * @ModelAttribute.
     */
    if (value.contains(" ") || value.contains(",")) {
      scope = OAuth2Utils.parseParameterList(value);
    }
  }
  this.scope = Collections
      .unmodifiableSet(scope == null ? new LinkedHashSet<String>()
          : new LinkedHashSet<String>(scope));
}

相关文章