当前位置: 首页>>代码示例>>Java>>正文


Java LinkedHashSet.addAll方法代码示例

本文整理汇总了Java中java.util.LinkedHashSet.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedHashSet.addAll方法的具体用法?Java LinkedHashSet.addAll怎么用?Java LinkedHashSet.addAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.LinkedHashSet的用法示例。


在下文中一共展示了LinkedHashSet.addAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAll

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Reads and returns the list of files stored in the data file.
 *
 * @return the list of files
 * @throws IOException if an exception occurs during file IO
 */
public static synchronized List<File> getAll() throws IOException {
    if (!AppData.getFile(DATA_FILE_NAME).exists()) {
        reset();
        return new ArrayList<>();
    }

    final String content = AppData.read(DATA_FILE_NAME);
    final LinkedHashSet<String> lines = new LinkedHashSet<>(Arrays.asList(content.split("\n")));

    // Remove any empty lines from the list of lines
    lines.removeIf(""::equals);

    final LinkedHashSet<File> files = new LinkedHashSet<>();

    files.addAll(lines.stream()
            .map(line -> new File(line.trim()))
            .collect(Collectors.toList()));

    return new ArrayList<>(truncate(files));
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:27,代码来源:RecentFiles.java

示例2: filter

import java.util.LinkedHashSet; //导入方法依赖的package包/类
Set<String> filter(SortedSet<String> allWords, String wanted) {
	if (wanted == null || wanted.isEmpty()) {
		return allWords;
	}
	LinkedHashSet<String> filtered = new LinkedHashSet<>();
	LinkedHashSet<String> addAfterEnd = new LinkedHashSet<>();
	String wantedLowerCase = wanted.toLowerCase();

	for (String word : allWords) {
		String wordLowerCase = word.toLowerCase();
		if (wordLowerCase.startsWith(wantedLowerCase)) {
			filtered.add(word);
		} else if (wordLowerCase.indexOf(wantedLowerCase) != -1) {
			addAfterEnd.add(word);
		}
	}
	filtered.addAll(addAfterEnd);
	/* remove wanted itself */
	filtered.remove(wanted);
	return filtered;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:22,代码来源:SimpleWordCodeCompletion.java

示例3: generateKey

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Key for a cache object is built from all the known Authorities (which can change dynamically so they must all be
 * used) the NodeRef ID and the permission reference itself. This gives a unique key for each permission test.
 */
Serializable generateKey(Set<String> auths, NodeRef nodeRef, PermissionReference perm, CacheType type)
{
    LinkedHashSet<Serializable> key = new LinkedHashSet<Serializable>();
    key.add(perm.toString());
    // We will just have to key our dynamic sets by username. We wrap it so as not to be confused with a static set
    if (auths instanceof AuthorityServiceImpl.UserAuthoritySet)
    {
        key.add((Serializable)Collections.singleton(((AuthorityServiceImpl.UserAuthoritySet)auths).getUsername()));
    }
    else
    {
        key.addAll(auths);            
    }        
    key.add(nodeRef);
    // Ensure some concept of node version or transaction is included in the key so we can track without cache replication 
    NodeRef.Status nodeStatus = nodeService.getNodeStatus(nodeRef);
    key.add(nodeStatus == null ? "null" : nodeStatus.getChangeTxnId());
    key.add(type);
    return key;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:PermissionServiceImpl.java

示例4: evaluate

import java.util.LinkedHashSet; //导入方法依赖的package包/类
public List<String> evaluate(List<String> input, String baseUrl) {
    LinkedHashSet<String> linkedHashSet = Sets.newLinkedHashSet();
    int i = 0;
    for (String str : input) {
        StringContext stringContext = new StringContext(baseUrl, str, input, i);
        Object calculate = stringFunction.calculate(stringContext);
        if ((calculate instanceof Strings)) {
            linkedHashSet.addAll((Strings) calculate);
        } else if (calculate instanceof CharSequence) {
            linkedHashSet.add(calculate.toString());
        } else {
            log.warn("result type for function: " + stringFunction.functionName() + " is not strings");

        }
        i++;
    }
    return Lists.newLinkedList(linkedHashSet);
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:19,代码来源:StingEvaluator.java

示例5: getCommonPredecessors

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/** see {@link N4JSFlowAnalyzer#getCommonPredecessors(ControlFlowElement , ControlFlowElement)}. */
public Set<ControlFlowElement> getCommonPredecessors(ControlFlowElement cfeA, ControlFlowElement cfeB) {
	Objects.requireNonNull(cfeA);
	Objects.requireNonNull(cfeB);

	LinkedHashSet<ControlFlowElement> commonPredSet = new LinkedHashSet<>();
	commonPredSet.addAll(getSomeCommonPredecessors(cfeA, cfeB));
	commonPredSet.addAll(getSomeCommonPredecessors(cfeB, cfeA));

	return commonPredSet;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:DirectPathAnalyses.java

示例6: add

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Adds the given file as entry to the data file.
 * <p>
 * This element is prepended to the front of the list. The list is truncated to the maximum size - if the list
 * already had the maximal number of entries, the last item will be (permanently) lost.
 *
 * @param file the file to be added
 * @throws IOException if an exception occurs during file IO
 */
public static synchronized void add(final File file) throws IOException {
    final LinkedHashSet<File> files = new LinkedHashSet<>();

    // Add new file to front of list and add previous items to the end
    files.add(file);
    files.addAll(getAll());

    final List<String> lines = truncate(files).stream().map(File::getPath).collect(Collectors.toList());
    final String fileContents = String.join("\n", lines);
    AppData.put(DATA_FILE_NAME, fileContents);
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:21,代码来源:RecentFiles.java

示例7: getCurrentPathSql

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Package-private for unit testing only.
 */
static String getCurrentPathSql(Connection conn, JdbcHelper jdbc, ImmutableSet<PhysicalSchema> physicalSchemas) {
    String path = jdbc.query(conn, "select current path from sysibm.sysdummy1", new ScalarHandler<String>());

    MutableList<String> currentSchemaPathList = Lists.mutable.of(path.split(",")).collect(new Function<String, String>() {
        @Override
        public String valueOf(String object) {
            if (object.startsWith("\"") && object.endsWith("\"")) {
                return object.substring(1, object.length() - 1);
            } else {
                return object;
            }
        }
    });

    // Rules on constructing this "set path" command:
    // 1) The existing default path must come first (respecting the existing connection), followed by the
    // schemas in our environment. The default path must take precedence.
    // 2) We cannot have duplicate schemas listed in the "set path" call; i.e. in case the schemas in our
    // environment config are already in the default schema.
    //
    // Given these two requirements, we use a LinkedHashSet
    LinkedHashSet<String> currentSchemaPaths = new LinkedHashSet(currentSchemaPathList);
    currentSchemaPaths.addAll(physicalSchemas.collect(PhysicalSchema.TO_PHYSICAL_NAME).castToSet());

    // This is needed to work w/ stored procedures
    // Ideally, we'd use "set current path current path, " + physicalSchemaList
    // However, we can't set this multiple times in a connection, as we can't have dupes in "current path"
    // Ideally, we could use BasicDataSource.initConnectionSqls, but this does not interoperate w/ the LDAP
    // datasource for JNDI-JDBC
    return "set path " + CollectionAdapter.adapt(currentSchemaPaths).makeString(",");
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:35,代码来源:Db2SqlExecutor.java

示例8: getIPs

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Returns all the IPs associated with the provided interface, if any, in
 * textual form.
 * 
 * @param strInterface
 *            The name of the network interface or sub-interface to query
 *            (eg eth0 or eth0:0) or the string "default"
 * @param returnSubinterfaces
 *            Whether to return IPs associated with subinterfaces of
 *            the given interface
 * @return A string vector of all the IPs associated with the provided
 *         interface. The local host IP is returned if the interface
 *         name "default" is specified or there is an I/O error looking
 *         for the given interface.
 * @throws UnknownHostException
 *             If the given interface is invalid
 * 
 */
public static String[] getIPs(String strInterface,
    boolean returnSubinterfaces) throws UnknownHostException {
  if ("default".equals(strInterface)) {
    return new String[] { cachedHostAddress };
  }
  NetworkInterface netIf;
  try {
    netIf = NetworkInterface.getByName(strInterface);
    if (netIf == null) {
      netIf = getSubinterface(strInterface);
    }
  } catch (SocketException e) {
    LOG.warn("I/O error finding interface " + strInterface +
        ": " + e.getMessage());
    return new String[] { cachedHostAddress };
  }
  if (netIf == null) {
    throw new UnknownHostException("No such interface " + strInterface);
  }

  // NB: Using a LinkedHashSet to preserve the order for callers
  // that depend on a particular element being 1st in the array.
  // For example, getDefaultIP always returns the first element.
  LinkedHashSet<InetAddress> allAddrs = new LinkedHashSet<InetAddress>();
  allAddrs.addAll(Collections.list(netIf.getInetAddresses()));
  if (!returnSubinterfaces) {
    allAddrs.removeAll(getSubinterfaceInetAddrs(netIf));
  }

  String ips[] = new String[allAddrs.size()];
  int i = 0;
  for (InetAddress addr : allAddrs) {
    ips[i++] = addr.getHostAddress();
  }
  return ips;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:55,代码来源:DNS.java

示例9: getFlavorsForNative

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Returns a <code>List</code> of <code>DataFlavor</code>s to which the
 * specified <code>String</code> native can be translated by the data
 * transfer subsystem. The <code>List</code> will be sorted from best
 * <code>DataFlavor</code> to worst. That is, the first
 * <code>DataFlavor</code> will best reflect data in the specified
 * native to a Java application.
 * <p>
 * If the specified native is previously unknown to the data transfer
 * subsystem, and that native has been properly encoded, then invoking this
 * method will establish a mapping in both directions between the specified
 * native and a <code>DataFlavor</code> whose MIME type is a decoded
 * version of the native.
 * <p>
 * If the specified native is not a properly encoded native and the
 * mappings for this native have not been altered with
 * <code>setFlavorsForNative</code>, then the contents of the
 * <code>List</code> is platform dependent, but <code>null</code>
 * cannot be returned.
 *
 * @param nat the native whose corresponding <code>DataFlavor</code>s
 *        should be returned. If <code>null</code> is specified, all
 *        <code>DataFlavor</code>s currently known to the data transfer
 *        subsystem are returned in a non-deterministic order.
 * @return a <code>java.util.List</code> of <code>DataFlavor</code>
 *         objects into which platform-specific data in the specified,
 *         platform-specific native can be translated
 *
 * @see #encodeJavaMIMEType
 * @since 1.4
 */
@Override
public synchronized List<DataFlavor> getFlavorsForNative(String nat) {
    LinkedHashSet<DataFlavor> returnValue = flavorsForNativeCache.check(nat);
    if (returnValue != null) {
        return new ArrayList<>(returnValue);
    } else {
        returnValue = new LinkedHashSet<>();
    }

    if (nat == null) {
        for (String n : getNativesForFlavor(null)) {
            returnValue.addAll(getFlavorsForNative(n));
        }
    } else {
        final LinkedHashSet<DataFlavor> flavors = nativeToFlavorLookup(nat);
        if (disabledMappingGenerationKeys.contains(nat)) {
            return new ArrayList<>(flavors);
        }

        final LinkedHashSet<DataFlavor> flavorsWithSynthesized =
                nativeToFlavorLookup(nat);

        for (DataFlavor df : flavorsWithSynthesized) {
            returnValue.add(df);
            if ("text".equals(df.getPrimaryType())) {
                String baseType = df.mimeType.getBaseType();
                returnValue.addAll(convertMimeTypeToDataFlavors(baseType));
            }
        }
    }
    flavorsForNativeCache.put(nat, returnValue);
    return new ArrayList<>(returnValue);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:65,代码来源:SystemFlavorMap.java

示例10: getAllShapes

import java.util.LinkedHashSet; //导入方法依赖的package包/类
@Override
public Set<DiagramShape> getAllShapes(boolean forJSON) {
  if (forJSON) {
    LinkedHashSet<DiagramShape> all = shapes.stream().filter(UMLClass.class::isInstance).collect(Collectors.toCollection(LinkedHashSet::new));
    all.addAll(shapes.stream().filter(Association.class::isInstance).collect(Collectors.toCollection(LinkedHashSet::new)));
    all.addAll(shapes.stream().filter(shape -> !(shape instanceof UMLClass) && !(shape instanceof Association)).collect(Collectors.toCollection(LinkedHashSet::new)));
    return all;
  }
  return shapes;
}
 
开发者ID:onprom,项目名称:onprom,代码行数:11,代码来源:UMLDiagramPanel.java

示例11: getFlavorsForNative

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Returns a {@code List} of {@code DataFlavor}s to which the specified
 * {@code String} native can be translated by the data transfer subsystem.
 * The {@code List} will be sorted from best {@code DataFlavor} to worst.
 * That is, the first {@code DataFlavor} will best reflect data in the
 * specified native to a Java application.
 * <p>
 * If the specified native is previously unknown to the data transfer
 * subsystem, and that native has been properly encoded, then invoking this
 * method will establish a mapping in both directions between the specified
 * native and a {@code DataFlavor} whose MIME type is a decoded version of
 * the native.
 * <p>
 * If the specified native is not a properly encoded native and the mappings
 * for this native have not been altered with {@code setFlavorsForNative},
 * then the contents of the {@code List} is platform dependent, but
 * {@code null} cannot be returned.
 *
 * @param  nat the native whose corresponding {@code DataFlavor}s should be
 *         returned. If {@code null} is specified, all {@code DataFlavor}s
 *         currently known to the data transfer subsystem are returned in a
 *         non-deterministic order.
 * @return a {@code java.util.List} of {@code DataFlavor} objects into which
 *         platform-specific data in the specified, platform-specific native
 *         can be translated
 * @see #encodeJavaMIMEType
 * @since 1.4
 */
@Override
public synchronized List<DataFlavor> getFlavorsForNative(String nat) {
    LinkedHashSet<DataFlavor> returnValue = flavorsForNativeCache.check(nat);
    if (returnValue != null) {
        return new ArrayList<>(returnValue);
    } else {
        returnValue = new LinkedHashSet<>();
    }

    if (nat == null) {
        for (String n : getNativesForFlavor(null)) {
            returnValue.addAll(getFlavorsForNative(n));
        }
    } else {
        final LinkedHashSet<DataFlavor> flavors = nativeToFlavorLookup(nat);
        if (disabledMappingGenerationKeys.contains(nat)) {
            return new ArrayList<>(flavors);
        }

        final LinkedHashSet<DataFlavor> flavorsWithSynthesized =
                nativeToFlavorLookup(nat);

        for (DataFlavor df : flavorsWithSynthesized) {
            returnValue.add(df);
            if ("text".equals(df.getPrimaryType())) {
                String baseType = df.mimeType.getBaseType();
                returnValue.addAll(convertMimeTypeToDataFlavors(baseType));
            }
        }
    }
    flavorsForNativeCache.put(nat, returnValue);
    return new ArrayList<>(returnValue);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:62,代码来源:SystemFlavorMap.java

示例12: getNativeLanguagesUsedByResource

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Find in the given resource the native languages corresponding to the element at the root of the resource
 * (built as a set in order to have no duplicate)
 * @param res
 * @return a list of all the native languages of the root elements of the resource  
 */
public static List<String> getNativeLanguagesUsedByResource(Resource res){
	LinkedHashSet<String> usedLanguages = new LinkedHashSet<String>();
	for(EObject eobj : res.getContents()){
		usedLanguages.addAll(getLanguageNamesForURI(eobj.eClass().eResource().getURI().toString()));
	}
	List<String> languagesNames = new ArrayList<String>();
	languagesNames.addAll(usedLanguages);
	return languagesNames;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:16,代码来源:MelangeHelper.java

示例13: getSubinterfaceInetAddrs

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * @param nif network interface to get addresses for
 * @return set containing addresses for each subinterface of nif,
 *    see below for the rationale for using an ordered set
 */
private static LinkedHashSet<InetAddress> getSubinterfaceInetAddrs(
    NetworkInterface nif) {
  LinkedHashSet<InetAddress> addrs = new LinkedHashSet<InetAddress>();
  Enumeration<NetworkInterface> subNifs = nif.getSubInterfaces();
  while (subNifs.hasMoreElements()) {
    NetworkInterface subNif = subNifs.nextElement();
    addrs.addAll(Collections.list(subNif.getInetAddresses()));
  }
  return addrs;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:DNS.java

示例14: BulkOperationCleanupAction

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Constructs an action to cleanup "affected cache regions" based on a
 * set of affected table spaces.  This differs from {@link #BulkOperationCleanupAction(SessionImplementor, Queryable[])}
 * in that here we have the affected <strong>table names</strong>.  From those
 * we deduce the entity persisters which are affected based on the defined
 * {@link EntityPersister#getQuerySpaces() table spaces}; and from there, we
 * determine the affected collection regions based on any collections
 * in which those entity persisters participate as elements/keys/etc.
 *
 * @param session The session to which this request is tied.
 * @param tableSpaces The table spaces.
 */
@SuppressWarnings({ "unchecked" })
public BulkOperationCleanupAction(SessionImplementor session, Set tableSpaces) {
	final LinkedHashSet<String> spacesList = new LinkedHashSet<String>();
	spacesList.addAll( tableSpaces );

	final SessionFactoryImplementor factory = session.getFactory();
	for ( String entityName : factory.getAllClassMetadata().keySet() ) {
		final EntityPersister persister = factory.getEntityPersister( entityName );
		final String[] entitySpaces = (String[]) persister.getQuerySpaces();
		if ( affectedEntity( tableSpaces, entitySpaces ) ) {
			spacesList.addAll( Arrays.asList( entitySpaces ) );

			if ( persister.hasCache() ) {
				entityCleanups.add( new EntityCleanup( persister.getCacheAccessStrategy() ) );
			}
			if ( persister.hasNaturalIdentifier() && persister.hasNaturalIdCache() ) {
				naturalIdCleanups.add( new NaturalIdCleanup( persister.getNaturalIdCacheAccessStrategy() ) );
			}

			final Set<String> roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() );
			if ( roles != null ) {
				for ( String role : roles ) {
					final CollectionPersister collectionPersister = factory.getCollectionPersister( role );
					if ( collectionPersister.hasCache() ) {
						collectionCleanups.add(
								new CollectionCleanup( collectionPersister.getCacheAccessStrategy() )
						);
					}
				}
			}
		}
	}

	this.affectedTableSpaces = spacesList.toArray( new String[ spacesList.size() ] );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:BulkOperationCleanupAction.java

示例15: flavorToNativeLookup

import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
 * Semantically equivalent to 'flavorToNative.get(flav)'. This method
 * handles the case where 'flav' is not found in 'flavorToNative' depending
 * on the value of passes 'synthesize' parameter. If 'synthesize' is
 * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by
 * encoding the DataFlavor's MIME type. Otherwise an empty List is returned
 * and 'flavorToNative' remains unaffected.
 */
private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
                                                   final boolean synthesize) {

    LinkedHashSet<String> natives = getFlavorToNative().get(flav);

    if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
        DesktopDatatransferService desktopService = DataFlavorUtil.getDesktopService();
        if (desktopService.isDesktopPresent()) {
            LinkedHashSet<String> platformNatives =
                    desktopService.getPlatformMappingsForFlavor(flav);
            if (!platformNatives.isEmpty()) {
                if (natives != null) {
                    // Prepend the platform-specific mappings to ensure
                    // that the natives added with
                    // addUnencodedNativeForFlavor() are at the end of
                    // list.
                    platformNatives.addAll(natives);
                }
                natives = platformNatives;
            }
        }
    }

    if (natives == null) {
        if (synthesize) {
            String encoded = encodeDataFlavor(flav);
            natives = new LinkedHashSet<>(1);
            getFlavorToNative().put(flav, natives);
            natives.add(encoded);

            LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
            if (flavors == null) {
                flavors = new LinkedHashSet<>(1);
                getNativeToFlavor().put(encoded, flavors);
            }
            flavors.add(flav);

            nativesForFlavorCache.remove(flav);
            flavorsForNativeCache.remove(encoded);
        } else {
            natives = new LinkedHashSet<>(0);
        }
    }

    return new LinkedHashSet<>(natives);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:SystemFlavorMap.java


注:本文中的java.util.LinkedHashSet.addAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。