Tabnine Logo
HashSet.contains
Code IndexAdd Tabnine to your IDE (free)

How to use
contains
method
in
java.util.HashSet

Best Java code snippets using java.util.HashSet.contains (Showing top 20 results out of 22,572)

Refine searchRefine arrow

  • HashSet.add
  • HashSet.<init>
  • Iterator.hasNext
  • Iterator.next
  • List.add
  • ArrayList.add
origin: prestodb/presto

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);
  }
}
origin: apache/storm

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;
  }
}
origin: jenkinsci/jenkins

@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;
}
origin: apache/storm

@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;
}
origin: fesh0r/fernflower

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();
  }
 }
}
origin: h2oai/h2o-3

/**
 * 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);
}
origin: apache/hive

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;
origin: hibernate/hibernate-orm

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( "'" );
  }
}
origin: alipay/sofa-rpc

  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());
origin: scouter-project/scouter

private void add(String objName, ObjectName mbean, String type, byte decimal, String attrName, String counterName) {
  if (errors.contains(attrName))
    return;
  MBeanObj cObj = new MBeanObj(objName, mbean, type, ValueEnum.DECIMAL, attrName, counterName);
  beanList.add(cObj);
}
origin: medcl/elasticsearch-analysis-pinyin

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);
}
origin: org.apache.commons/commons-collections4

/**
 * 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;
}
origin: apache/hive

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;
}
origin: medcl/elasticsearch-analysis-pinyin

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);
}
origin: alibaba/jstorm

@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;
}
origin: Activiti/Activiti

/**
 * 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;
}
origin: k9mail/k-9

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);
}
origin: apache/drill

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;
origin: robovm/robovm

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;
}
origin: alipay/sofa-rpc

  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);
java.utilHashSetcontains

Javadoc

Searches this HashSet for the specified object.

Popular methods of HashSet

  • <init>
  • add
    Adds the specified element to this set if it is not already present. More formally, adds the specifi
  • size
    Returns the number of elements in this set (its cardinality).
  • addAll
  • remove
    Removes the specified element from this set if it is present. More formally, removes an element e su
  • iterator
    Returns an iterator over the elements in this set. The elements are returned in no particular order.
  • isEmpty
    Returns true if this set contains no elements.
  • clear
    Removes all of the elements from this set. The set will be empty after this call returns.
  • toArray
  • removeAll
  • equals
  • clone
    Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
  • equals,
  • clone,
  • retainAll,
  • stream,
  • containsAll,
  • forEach,
  • hashCode,
  • toString,
  • removeIf

Popular in Java

  • Making http post requests using okhttp
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • Menu (java.awt)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now