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

How to use
forEach
method
in
java.util.HashSet

Best Java code snippets using java.util.HashSet.forEach (Showing top 20 results out of 666)

origin: jersey/jersey

/**
 * Release a single reference to the current request scope instance.
 * <p>
 * Once all instance references are released, the instance will be recycled.
 */
@Override
public void release() {
  if (referenceCounter.decrementAndGet() < 1) {
    try {
      new HashSet<>(store.keySet()).forEach(this::remove);
    } finally {
      logger.debugLog("Released scope instance {0}", this);
    }
  }
}
origin: jersey/jersey

/**
 * Release a single reference to the current request scope instance.
 * <p>
 * Once all instance references are released, the instance will be recycled.
 */
@Override
public void release() {
  if (referenceCounter.decrementAndGet() < 1) {
    try {
      new HashSet<>(store.keySet()).forEach(this::remove);
    } finally {
      logger.debugLog("Released scope instance {0}", this);
    }
  }
}
origin: stanfordnlp/CoreNLP

public void predict(Set<String> predictedRelationsRaw, Set<String> goldRelationsRaw) {
 Set<String> predictedRelations = new HashSet<>(predictedRelationsRaw);
 predictedRelations.remove(NO_RELATION);
 Set<String> goldRelations = new HashSet<>(goldRelationsRaw);
 goldRelations.remove(NO_RELATION);
 // Register the prediction
 for (String pred : predictedRelations) {
  if (goldRelations.contains(pred)) {
   correctCount.incrementCount(pred);
  }
  predictedCount.incrementCount(pred);
 }
 goldRelations.forEach(goldCount::incrementCount);
 HashSet<String> allRelations = new HashSet<String>(){{ addAll(predictedRelations); addAll(goldRelations); }};
 allRelations.forEach(totalCount::incrementCount);
 // Register the confusion matrix
 if (predictedRelations.size() == 1 && goldRelations.size() == 1) {
  confusion.add(predictedRelations.iterator().next(), goldRelations.iterator().next());
 }
 if (predictedRelations.size() == 1 && goldRelations.isEmpty()) {
  confusion.add(predictedRelations.iterator().next(), "NR");
 }
 if (predictedRelations.isEmpty() && goldRelations.size() == 1) {
  confusion.add("NR", goldRelations.iterator().next());
 }
}
origin: Netflix/genie

CommandFactory(
  final List<AgentCommandArguments> agentCommandArguments,
  final ApplicationContext applicationContext
) {
  this.agentCommandArgumentsBeans = agentCommandArguments;
  this.applicationContext = applicationContext;
  agentCommandArguments.forEach(
    commandArgs -> {
      Sets.newHashSet(commandArgs.getClass().getAnnotation(Parameters.class).commandNames()).forEach(
        commandName -> {
          commandMap.put(commandName, commandArgs.getConsumerClass());
        }
      );
    }
  );
}
origin: OpenHFT/Chronicle-Queue

  private String buildDiffs() {
    final StringBuilder builder = new StringBuilder();
    builder.append("acquired but not released:\n");
    HashSet<String> keyDiff = new HashSet<>(acquiredCounts.keySet());
    keyDiff.removeAll(releasedCounts.keySet());
    keyDiff.forEach(k -> {
      builder.append(k).append("(").append(acquiredCounts.get(k)).append(")\n");
    });
    builder.append("released but not acquired:\n");
    keyDiff.clear();
    keyDiff.addAll(releasedCounts.keySet());
    keyDiff.removeAll(acquiredCounts.keySet());
    keyDiff.forEach(k -> {
      builder.append(k).append("(").append(releasedCounts.get(k)).append(")\n");
    });
    return builder.toString();
  }
}
origin: spring-projects/spring-security

@Test
public void headersWhenDisableThenNoSecurityHeaders() {
  new HashSet<>(this.expectedHeaders.keySet()).forEach(this::expectHeaderNamesNotPresent);
  this.headers.disable();
  assertHeaders();
}
origin: com.vaadin/vaadin-server

  @Override
  public void destroyAllData() {
    // Make a defensive copy of keys, as the map gets cleared when
    // removing components.
    new HashSet<>(activeComponents.keySet())
        .forEach(component -> removeComponent(component));
  }
};
origin: requery/requery

attributeNames.forEach(name -> block.add(".addAttribute($L)\n", name));
expressionNames.forEach(name -> block.add(".addExpression($L)\n", name));
block.add(".build()");
ParameterizedTypeName type = parameterizedTypeName(Type.class, targetName);
origin: palatable/lambda

/**
 * A lens that focuses on the keys of a map.
 *
 * @param <K> the key type
 * @param <V> the value type
 * @return a lens that focuses on the keys of a map
 */
public static <K, V> Lens.Simple<Map<K, V>, Set<K>> keys() {
  return simpleLens(m -> new HashSet<>(m.keySet()), (m, ks) -> {
    HashSet<K> ksCopy = new HashSet<>(ks);
    Map<K, V> updated = new HashMap<>(m);
    Set<K> keys = updated.keySet();
    keys.retainAll(ksCopy);
    ksCopy.removeAll(keys);
    ksCopy.forEach(k -> updated.put(k, null));
    return updated;
  });
}
origin: zstackio/zstack

private void reScanHost(boolean skipExisting) {
  if (!skipExisting) {
    new HashSet<>(trackers.values()).forEach(Tracker::cancel);
  }
  new SQLBatch() {
    @Override
    protected void scripts() {
      long count = sql("select count(h) from HostVO h", Long.class).find();
      sql("select h.uuid from HostVO h", String.class).limit(1000).paginate(count, (List<String> hostUuids) -> {
        List<String> byUs = hostUuids.stream().filter(huuid -> {
          if (skipExisting) {
            return destMaker.isManagedByUs(huuid) && !trackers.containsKey(huuid);
          } else {
            return destMaker.isManagedByUs(huuid);
          }
        }).collect(Collectors.toList());
        trackHost(byUs);
      });
    }
  }.execute();
}
origin: com.vaadin/flow-data

private void unregisterPassivatedKeys() {
  /*
   * Actually unregister anything that was removed in an update that the
   * client has confirmed that it has applied.
   */
  if (!confirmedUpdates.isEmpty()) {
    confirmedUpdates.forEach(this::doUnregister);
    confirmedUpdates.clear();
  }
}
origin: neo4j-contrib/neo4j-graph-algorithms

/**
 * run node consumer in tx as long as he returns true
 *
 * @param consumer the node consumer
 * @return child instance to make methods of the child class accessible.
 */
public ME forEachNodeInTx(Consumer<Node> consumer) {
  withinTransaction(() -> nodes.forEach(consumer));
  return self;
}
origin: docbleach/DocBleach

protected static void removeObProjRecord(Collection<Record> records) {
 new HashSet<>(records)
   .forEach(
     record -> {
      if (!isObProj(record)) {
       return;
      }
      records.remove(record);
      LOGGER.debug("Found and removed ObProj record: {}", record);
     });
}
origin: org.neo4j/graph-algorithms-core

/**
 * run node consumer in tx as long as he returns true
 *
 * @param consumer the node consumer
 * @return child instance to make methods of the child class accessible.
 */
public ME forEachNodeInTx(Consumer<Node> consumer) {
  withinTransaction(() -> nodes.forEach(consumer));
  return self;
}
origin: Camelcade/Perl5-IDEA

public PerlBuiltInVariablesService(Project project) {
 myPsiManager = PsiManager.getInstance(project);
 for (int i = 1; i <= 20; i++) {
  String variableName = Integer.toString(i);
  myScalars.put(variableName, new PerlBuiltInVariable(myPsiManager, "$" + variableName));
 }
 PerlBuiltInScalars.BUILT_IN.forEach(name -> myScalars.put(name, new PerlBuiltInVariable(myPsiManager, "$" + name)));
 PerlArrayUtil.BUILT_IN.forEach(name -> myArrays.put(name, new PerlBuiltInVariable(myPsiManager, "@" + name)));
 PerlHashUtil.BUILT_IN.forEach(name -> myHashes.put(name, new PerlBuiltInVariable(myPsiManager, "%" + name)));
 PerlGlobUtil.BUILT_IN.forEach(name -> myGlobs.put(name, new PerlBuiltInVariable(myPsiManager, "*" + name)));
}
origin: semantic-integration/hypergraphql

public String toString(int i) {
  StringBuilder result = new StringBuilder();
  getForest().forEach(node -> result.append(node.toString(i)));
  return result.toString();
}
origin: semantic-integration/hypergraphql

public Map<String, String> getFullLdContext() {
  Map<String, String> result = new HashMap<>();
  getForest().forEach(child -> result.putAll(child.getFullLdContext()));
  return result;
}
origin: semantic-integration/hypergraphql

public Map<String, String> getFullLdContext() {
  Map<String, String> result = new HashMap<>();
  getForest().forEach(child -> result.putAll(child.getFullLdContext()));
  return result;
}
origin: halirutan/Mathematica-IntelliJ-Plugin

private PsiElement[] findLightSymbolDeclarations(@NotNull LightSymbol lightSymbol) {
 SortedSet<PsiElement> result = new TreeSet<>(Comparator.comparing(PsiElement::getTextOffset));
 GlobalDefinitionCollector coll = new GlobalDefinitionCollector(lightSymbol.getContainingFile());
 if (coll.getAssignments().containsKey(lightSymbol.getName())) {
  coll.getAssignments().get(lightSymbol.getName()).forEach(
    assignmentProperty -> result.add(assignmentProperty.myLhsOfAssignment));
 }
 return result.toArray(PsiElement.EMPTY_ARRAY);
}
origin: CorfuDB/CorfuDB

@After
public void shutdownServers() {
  new HashSet<>(serverRouter.handlerMap.values()).forEach(AbstractServer::shutdown);
}
java.utilHashSetforEach

Popular methods of HashSet

  • <init>
  • add
    Adds the specified element to this set if it is not already present. More formally, adds the specifi
  • contains
    Returns true if this set contains the specified element. More formally, returns true if and only if
  • 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
  • removeAll,
  • equals,
  • clone,
  • retainAll,
  • stream,
  • containsAll,
  • hashCode,
  • toString,
  • removeIf

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setRequestProperty (URLConnection)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Table (org.hibernate.mapping)
    A relational table
  • CodeWhisperer alternatives
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