private static void addNamedGroups(Pattern pattern, HashSet<String> variables) { Matcher matcher = NAMED_GROUPS_PATTERN.matcher(pattern.toString()); while (matcher.find()) { String name = matcher.group(1); checkArgument(!variables.contains(name), "Multiple definitions found for variable ${" + name + "}"); variables.add(name); } }
public StringValidator(Map<String, Object> params) { this.acceptedValues = new HashSet<String>(Arrays.asList((String[]) params.get(ConfigValidationAnnotations.ValidatorParams.ACCEPTED_VALUES))); if (this.acceptedValues.isEmpty() || (this.acceptedValues.size() == 1 && this.acceptedValues.contains(""))) { this.acceptedValues = null; } }
@Override protected int act(List<Run<?, ?>> builds) throws IOException { job.checkPermission(Run.DELETE); final HashSet<Integer> hsBuilds = new HashSet<>(); for (Run<?, ?> build : builds) { if (!hsBuilds.contains(build.number)) { build.delete(); hsBuilds.add(build.number); } } stdout.println("Deleted "+hsBuilds.size()+" builds"); return 0; }
@Override public Collection<Node> takeNodes(int nodesNeeded) { LOG.debug("Taking {} from {}", nodesNeeded, this); HashSet<Node> ret = new HashSet<>(); for (Entry<String, Set<Node>> entry : _topologyIdToNodes.entrySet()) { if (!_isolated.contains(entry.getKey())) { Iterator<Node> it = entry.getValue().iterator(); while (it.hasNext()) { if (nodesNeeded <= 0) { return ret; } Node n = it.next(); it.remove(); n.freeAllSlots(_cluster); ret.add(n); nodesNeeded--; _usedNodes--; } } } return ret; }
private static void addToReversePostOrderListIterative(DirectNode root, List<DirectNode> lst) { LinkedList<DirectNode> stackNode = new LinkedList<>(); LinkedList<Integer> stackIndex = new LinkedList<>(); HashSet<DirectNode> setVisited = new HashSet<>(); stackNode.add(root); stackIndex.add(0); while (!stackNode.isEmpty()) { DirectNode node = stackNode.getLast(); int index = stackIndex.removeLast(); setVisited.add(node); for (; index < node.succs.size(); index++) { DirectNode succ = node.succs.get(index); if (!setVisited.contains(succ)) { stackIndex.add(index + 1); stackNode.add(succ); stackIndex.add(0); break; } } if (index == node.succs.size()) { lst.add(0, node); stackNode.removeLast(); } } }
/** * Get the non-ignored columns that are not in the filter; do not include the response. * @param filterThese remove these columns * @return an int[] of the non-ignored column indexes */ public int[] diffCols(int[] filterThese) { HashSet<Integer> filter = new HashSet<>(); for(int i:filterThese)filter.add(i); ArrayList<Integer> res = new ArrayList<>(); for(int i=0;i<_cols.length;++i) { if( _cols[i]._ignored || _cols[i]._response || filter.contains(i) ) continue; res.add(i); } return intListToA(res); }
HashSet<Node> addedNodes = new HashSet<Node>(); for (Node node : startNodes) { addedNodes.add(node); (Operator<? extends OperatorDesc>) child; if (!addedNodes.contains(child) && (childOP.getParentOperators() == null || addedNodes.containsAll(childOP.getParentOperators()))) { toWalk.add(child); addedNodes.add(child); if (!nodeTypes.isEmpty() && !nodeTypes.contains(nd.getClass())) { continue;
private static void appendTokens(StringBuilder buf, Iterator iter) { boolean lastSpaceable = true; boolean lastQuoted = false; while ( iter.hasNext() ) { String token = (String) iter.next(); boolean spaceable = !DONT_SPACE_TOKENS.contains( token ); boolean quoted = token.startsWith( "'" ); if ( spaceable && lastSpaceable ) { if ( !quoted || !lastQuoted ) { buf.append( ' ' ); } } lastSpaceable = spaceable; buf.append( token ); lastQuoted = token.endsWith( "'" ); } }
for (String filterAlias : filterAliases) { if (startsWithExcludePrefix(filterAlias)) { // 排除用的特殊字符 excludes.add(filterAlias.substring(1)); } else { ExtensionClass<Filter> filter = EXTENSION_LOADER.getExtensionClass(filterAlias); if (filter != null) { extensionFilters.add(filter); if (!excludes.contains(StringUtils.ALL) && !excludes.contains(StringUtils.DEFAULT)) { // 配了-*和-default表示不加载内置 for (Map.Entry<String, ExtensionClass<Filter>> entry : autoActiveFilters.entrySet()) { if (!excludes.contains(entry.getKey())) { extensionFilters.add(entry.getValue()); actualFilters.add(extensionFilter.getExtInstance());
void addCandidate(TermItem item) { String term = item.term; if (config.lowercase) { term = term.toLowerCase(); } if (config.trimWhitespace) { term = term.trim(); } item.term = term; if (term.length() == 0) { return; } //remove same term with same position String fr=term+item.position; //remove same term, regardless position if (config.removeDuplicateTerm) { fr=term; } if (termsFilter.contains(fr)) { return; } termsFilter.add(fr); candidate.add(item); }
/** * Returns a new list containing all elements that are contained in * both given lists. * * @param <E> the element type * @param list1 the first list * @param list2 the second list * @return the intersection of those two lists * @throws NullPointerException if either list is null */ public static <E> List<E> intersection(final List<? extends E> list1, final List<? extends E> list2) { final List<E> result = new ArrayList<>(); List<? extends E> smaller = list1; List<? extends E> larger = list2; if (list1.size() > list2.size()) { smaller = list2; larger = list1; } final HashSet<E> hashSet = new HashSet<>(smaller); for (final E e : larger) { if (hashSet.contains(e)) { result.add(e); hashSet.remove(e); } } return result; }
protected List<Integer> getBucketColIDs(List<String> bucketCols, List<FieldSchema> cols) { ArrayList<Integer> result = new ArrayList<>(bucketCols.size()); HashSet<String> bucketSet = new HashSet<>(bucketCols); for (int i = 0; i < cols.size(); i++) { if (bucketSet.contains(cols.get(i).getName())) { result.add(i); } } return result; }
void addCandidate(TermItem item) { String term = item.term; if (config.lowercase) { term = term.toLowerCase(); } if (config.trimWhitespace) { term = term.trim(); } item.term = term; if (term.length() == 0) { return; } //remove same term with same position String fr=term+item.position; //remove same term, regardless position if (config.removeDuplicateTerm) { fr=term; } if (termsFilter.contains(fr)) { return; } termsFilter.add(fr); candidate.add(item); }
@Override public Collection<Node> takeNodes(int nodesNeeded) { LOG.debug("Taking {} from {}", nodesNeeded, this); HashSet<Node> ret = new HashSet<>(); for (Entry<String, Set<Node>> entry : _topologyIdToNodes.entrySet()) { if (!_isolated.contains(entry.getKey())) { Iterator<Node> it = entry.getValue().iterator(); while (it.hasNext()) { if (nodesNeeded <= 0) { return ret; } Node n = it.next(); it.remove(); n.freeAllSlots(_cluster); ret.add(n); nodesNeeded--; _usedNodes--; } } } return ret; }
/** * Takes in a collection of executions belonging to the same process instance. Orders the executions in a list, first elements are the leaf, last element is the root elements. */ public static List<ExecutionEntity> orderFromRootToLeaf(Collection<ExecutionEntity> executions) { List<ExecutionEntity> orderedList = new ArrayList<ExecutionEntity>(executions.size()); // Root elements HashSet<String> previousIds = new HashSet<String>(); for (ExecutionEntity execution : executions) { if (execution.getParentId() == null) { orderedList.add(execution); previousIds.add(execution.getId()); } } // Non-root elements while (orderedList.size() < executions.size()) { for (ExecutionEntity execution : executions) { if (!previousIds.contains(execution.getId()) && previousIds.contains(execution.getParentId())) { orderedList.add(execution); previousIds.add(execution.getId()); } } } return orderedList; }
public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) { List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to); HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses); ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses); ArrayList<Address> ccAddresses = new ArrayList<>(); for (Address address : message.getFrom()) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.CC)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { ccAddresses.add(address); alreadyAddedAddresses.add(address); } } return new ReplyToAddresses(toAddresses, ccAddresses); }
HashSet<Node> addedNodes = new HashSet<Node>(); for (Node node : startNodes) { addedNodes.add(node); (Operator<? extends OperatorDesc>) child; if (!addedNodes.contains(child) && (childOP.getParentOperators() == null || addedNodes.containsAll(childOP.getParentOperators()))) { toWalk.add(child); addedNodes.add(child); if (!nodeTypes.isEmpty() && !nodeTypes.contains(nd.getClass())) { continue;
public Map<Attribute, Object> getAttributes() { Map<Attribute, Object> result = new HashMap<Attribute, Object>( (attrString.attributeMap.size() * 4 / 3) + 1); Iterator<Map.Entry<Attribute, List<Range>>> it = attrString.attributeMap .entrySet().iterator(); while (it.hasNext()) { Map.Entry<Attribute, List<Range>> entry = it.next(); if (attributesAllowed == null || attributesAllowed.contains(entry.getKey())) { Object value = currentValue(entry.getValue()); if (value != null) { result.put(entry.getKey(), value); } } } return result; }
for (String routerAlias : routerAliases) { if (startsWithExcludePrefix(routerAlias)) { // 排除用的特殊字符 excludes.add(routerAlias.substring(1)); } else { extensionRouters.add(EXTENSION_LOADER.getExtensionClass(routerAlias)); if (!excludes.contains(StringUtils.ALL) && !excludes.contains(StringUtils.DEFAULT)) { // 配了-*和-default表示不加载内置 for (Map.Entry<String, ExtensionClass<Router>> entry : CONSUMER_AUTO_ACTIVES.entrySet()) { if (!excludes.contains(entry.getKey())) { extensionRouters.add(entry.getValue()); for (ExtensionClass<Router> extensionRouter : extensionRouters) { Router actualRoute = extensionRouter.getExtInstance(); actualRouters.add(actualRoute);