Tabnine Logo
HashMap.compute
Code IndexAdd Tabnine to your IDE (free)

How to use
compute
method
in
java.util.HashMap

Best Java code snippets using java.util.HashMap.compute (Showing top 20 results out of 1,179)

origin: org.apache.lucene/lucene-core

/** find repeating terms and assign them ordinal values */
private LinkedHashMap<Term,Integer> repeatingTerms() {
 LinkedHashMap<Term,Integer> tord = new LinkedHashMap<>();
 HashMap<Term,Integer> tcnt = new HashMap<>();
 for (PhrasePositions pp : phrasePositions) {
  for (Term t : pp.terms) {
   Integer cnt = tcnt.compute(t, (key, old) -> old == null ? 1 : 1 + old);
   if (cnt==2) {
    tord.put(t,tord.size());
   }
  }
 }
 return tord;
}
origin: neo4j/neo4j

static Map<String,Integer> count(
    org.neo4j.internal.kernel.api.Transaction transaction,
    RelationshipTraversalCursor relationship ) throws KernelException
{
  HashMap<String,Integer> counts = new HashMap<>();
  while ( relationship.next() )
  {
    String key = computeKey( transaction, relationship );
    counts.compute( key, ( k, value ) -> value == null ? 1 : value + 1 );
  }
  return counts;
}
origin: com.typesafe.play/play_2.11

/**
 * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
  return super.compute(key, remappingFunction);
}
origin: com.typesafe.play/play_2.11

/**
 * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
  return super.compute(key, remappingFunction);
}
origin: com.typesafe.play/play_2.12

/**
 * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
  return super.compute(key, remappingFunction);
}
origin: com.typesafe.play/play

/**
 * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
  return super.compute(key, remappingFunction);
}
origin: com.typesafe.play/play_2.12

/**
 * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
  return super.compute(key, remappingFunction);
}
origin: com.typesafe.play/play

/**
 * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
  return super.compute(key, remappingFunction);
}
origin: de.mhus.lib/mhu-lib-core

@Override
public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
  return map.compute(key, remappingFunction);
}
origin: de.mhus.lib/mhu-lib-core

@Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
  return map.compute(key, remappingFunction);
}
origin: stackoverflow.com

 final HashMap<Integer, Integer> map = new HashMap<Integer,Integer>();
map.put(123, 456);
System.out.println(map);
final int x = 234;
final BiFunction<? super Integer, ? super Integer, ? extends Integer> f =
  (k, v) -> v == null ? x : Math.min(v, x);
map.compute(123, f);
map.compute(999, f);
System.out.println(map);
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/** find repeating terms and assign them ordinal values */
private LinkedHashMap<Term,Integer> repeatingTerms() {
 LinkedHashMap<Term,Integer> tord = new LinkedHashMap<>();
 HashMap<Term,Integer> tcnt = new HashMap<>();
 for (PhrasePositions pp : phrasePositions) {
  for (Term t : pp.terms) {
   Integer cnt = tcnt.compute(t, (key, old) -> old == null ? 1 : 1 + old);
   if (cnt==2) {
    tord.put(t,tord.size());
   }
  }
 }
 return tord;
}
origin: com.microsoft.azure/azure-cosmosdb-gateway

@Override
public V compute(String key, BiFunction<? super String, ? super V, ? extends V> remappingFunction) {
  return super.compute(safeToLower(key), remappingFunction);
}
origin: stackoverflow.com

public static void main(final String[] arrg) {
 final HashMap<Integer, Integer> map = new HashMap<Integer,Integer>();
 map.put(123, 456);
 System.out.println(map);
 map.compute(123, f(345));
 map.compute(123, f(99999));
 map.compute(999, f(888));
 System.out.println(map);
}
static BiFunction<? super Integer, ? super Integer, ? extends Integer> f(final int x) {
 return (k, v) -> v == null ? x : Math.min(v, x);
}
origin: stackoverflow.com

 HashMap<Integer, Integer> num_freq = new HashMap<>();

String input = "10:05"; // Example input

char[] input_chars = input.toCharArray();

for(char c : input_chars){
  // Accept only characters that are digits
  if(Character.isDigit(c)){
    // Grabs digit from character

    int num = Character.digit(c, 10);

    // Put 1 into map if no entry exists, else increment existing value

    num_freq.compute(num, (k_num, freq) -> freq == null ? 1 : freq + 1);
  }
}

// Print result out

num_freq.forEach((num, freq) -> {
  System.out.println("Digit " + num + " appears " + freq + " time(s)");
});
origin: org.graalvm.compiler/compiler

  public void accept(Collection<T> elements) {
    /* First compute the histogram. */
    HashMap<T, Integer> histogram = new HashMap<>();
    for (T e : elements) {
      histogram.compute(e, (key, count) -> (count == null) ? 1 : count + 1);
    }
    /* Then create the summary statistics. */
    for (Map.Entry<T, Integer> entry : histogram.entrySet()) {
      T element = entry.getKey();
      Integer count = entry.getValue();
      types.computeIfAbsent(element, key -> new IntSummaryStatistics()).accept(count.intValue());
    }
  }
}
origin: stanford-futuredata/macrobase

candidateCounts.compute(candidate, (k, v) -> v == null ? 1 : v + 1);
foundSupportInTxn = true;
origin: anba/es6draft

@Function(name = "count", arity = 0)
public void count(ExecutionContext cx, Object label) {
  String message, key;
  if (Type.isUndefined(label)) {
    StackTraceElement frame = StackTraces.stackTraceStream(new Throwable()).findFirst().get();
    key = frameToString(frame);
    message = "default";
  } else {
    key = ToFlatString(cx, label);
    message = key;
  }
  labels.compute(key, (k, c) -> c != null ? c + 1 : 1);
  println(cx, LogLevel.Info, String.format("%s: %d", message, labels.get(key)));
}
origin: Baqend/Orestes-Bloomfilter

countMap.compute(position, (k, v) -> (v == null) ? 1 : (v + 1));
origin: com.miglayout/miglayout-javafx

transMap.compute(TransType.OPACITY, (transType, oldTrans) -> {
  if (toOpacity != -1) {
    if (oldTrans != null)
  transMap.compute(TransType.BOUNDS, (transType, oldTrans) -> {
    Rectangle2D curBounds = getBounds(node);
java.utilHashMapcompute

Popular methods of HashMap

  • <init>
    Constructs a new HashMap instance containing the mappings from the specified map.
  • put
    Maps the specified key to the specified value.
  • get
    Returns the value of the mapping with the specified key.
  • containsKey
    Returns whether this map contains the specified key.
  • keySet
    Returns a set of the keys contained in this map. The set is backed by this map so changes to one are
  • remove
  • entrySet
    Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry.
  • values
    Returns a collection of the values contained in this map. The collection is backed by this map so ch
  • size
    Returns the number of elements in this map.
  • clear
    Removes all mappings from this hash map, leaving it empty.
  • isEmpty
    Returns whether this map is empty.
  • putAll
    Copies all the mappings in the specified map to this map. These mappings will replace all mappings t
  • isEmpty,
  • putAll,
  • clone,
  • toString,
  • containsValue,
  • equals,
  • hashCode,
  • computeIfAbsent,
  • getOrDefault,
  • forEach

Popular in Java

  • Updating database using SQL prepared statement
  • getSystemService (Context)
  • findViewById (Activity)
  • scheduleAtFixedRate (Timer)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Reference (javax.naming)
  • JButton (javax.swing)
  • Best plugins for Eclipse
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