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

How to use
put
method
in
java.util.HashMap

Best Java code snippets using java.util.HashMap.put (Showing top 20 results out of 92,358)

Refine searchRefine arrow

  • HashMap.get
  • HashMap.<init>
  • HashMap.containsKey
  • Map.Entry.getKey
  • Map.Entry.getValue
  • ArrayList.<init>
  • ArrayList.add
  • PrintStream.println
origin: google/guava

 private static <K, V> HashMap<K, V> newHashMap(
   Collection<? extends Entry<? extends K, ? extends V>> entries) {
  HashMap<K, V> map = new HashMap<>();
  for (Entry<? extends K, ? extends V> entry : entries) {
   map.put(entry.getKey(), entry.getValue());
  }
  return map;
 }
}
origin: libgdx/libgdx

public final int[] getIntArray(int argLength) {
 if (!aints.containsKey(argLength)) {
  aints.put(argLength, new int[argLength]);
 }
 assert (aints.get(argLength).length == argLength) : "Array not built with correct length";
 return aints.get(argLength);
}
origin: Tencent/tinker

void putSanitizeName(RType rType, String sanitizeName, String rawName) {
  HashMap<String, String> sanitizeNameMap;
  if (!sanitizeTypeMap.containsKey(rType)) {
    sanitizeNameMap = new HashMap<>();
    sanitizeTypeMap.put(rType, sanitizeNameMap);
  } else {
    sanitizeNameMap = sanitizeTypeMap.get(rType);
  }
  if (!sanitizeNameMap.containsKey(sanitizeName)) {
    sanitizeNameMap.put(sanitizeName, rawName);
  }
}
origin: alibaba/jstorm

public static <V> HashMap<V, Integer> multi_set(List<V> list) {
  HashMap<V, Integer> rtn = new HashMap<>();
  for (V v : list) {
    int cnt = 1;
    if (rtn.containsKey(v)) {
      cnt += rtn.get(v);
    }
    rtn.put(v, cnt);
  }
  return rtn;
}
origin: apache/hive

private static Map<String, Object> createVersions() {
 ArrayList<String> versions = new ArrayList<String>();
 versions.add(VERSION);
 HashMap<String, Object> res = new HashMap<String, Object>();
 res.put("supportedVersions", versions);
 res.put("version", VERSION);
 return Collections.unmodifiableMap(res);
}
origin: apache/storm

public static void registerMetricsConsumer(Map<String, Object> conf, Class klass, Object argument, long parallelismHint) {
  HashMap<String, Object> m = new HashMap<>();
  m.put("class", klass.getCanonicalName());
  m.put("parallelism.hint", parallelismHint);
  m.put("argument", argument);
  List l = (List) conf.get(TOPOLOGY_METRICS_CONSUMER_REGISTER);
  if (l == null) {
    l = new ArrayList();
  }
  l.add(m);
  conf.put(TOPOLOGY_METRICS_CONSUMER_REGISTER, l);
}
origin: stackoverflow.com

 HashMap<Integer, String> map = new HashMap<Integer, String>();
map.put (1, "Mark");
map.put (2, "Tarryn");
List<String> list = new ArrayList<String>(map.values());
for (String s : list) {
  System.out.println(s);
}
origin: apache/rocketmq

private HashMap<String/* brokerName */, Set<MessageQueue>> buildProcessQueueTableByBrokerName() {
  HashMap<String, Set<MessageQueue>> result = new HashMap<String, Set<MessageQueue>>();
  for (MessageQueue mq : this.processQueueTable.keySet()) {
    Set<MessageQueue> mqs = result.get(mq.getBrokerName());
    if (null == mqs) {
      mqs = new HashSet<MessageQueue>();
      result.put(mq.getBrokerName(), mqs);
    }
    mqs.add(mq);
  }
  return result;
}
origin: stackoverflow.com

HashMap<String, Double> map = new HashMap<String, Double>();
ValueComparator bvc = new ValueComparator(map);
TreeMap<String, Double> sorted_map = new TreeMap<String, Double>(bvc);
map.put("A", 99.5);
map.put("B", 67.4);
map.put("C", 67.4);
map.put("D", 67.3);
System.out.println("unsorted map: " + map);
sorted_map.putAll(map);
System.out.println("results: " + sorted_map);
origin: FudanNLP/fnlp

private int add(Word w) {
  Integer id = index.get(w.word);
  if(id==null){
    id = words.size();
    words.add(w);
    index.put(w.word, id);
  }
  return id;
}
origin: apache/kafka

@Override
public Map<Errors, Integer> errorCounts() {
  HashMap<Errors, Integer> counts = new HashMap<>();
  for (ReplicaElectionResult result : data.replicaElectionResults()) {
    for (PartitionResult partitionResult : result.partitionResult()) {
      Errors error = Errors.forCode(partitionResult.errorCode());
      counts.put(error, counts.getOrDefault(error, 0) + 1);
    }
  }
  return counts;
}
origin: libgdx/libgdx

public void setEnabled (ParticleEmitter emitter, boolean enabled) {
  ParticleData data = particleData.get(emitter);
  if (data == null) particleData.put(emitter, data = new ParticleData());
  data.enabled = enabled;
  emitter.reset();
}
origin: stackoverflow.com

 List<Integer> numbers = new ArrayList<Integer>(){{ add(1); add(2); }};

Map<String,String> codes = new HashMap<String,String>(){{ 
 put("1","one"); 
 put("2","two");
}};
origin: apache/rocketmq

public void buildRunningStats(HashMap<String, String> stats) {
  Iterator<Entry<Integer, Long>> it = this.offsetTable.entrySet().iterator();
  while (it.hasNext()) {
    Entry<Integer, Long> next = it.next();
    int queueId = delayLevel2QueueId(next.getKey());
    long delayOffset = next.getValue();
    long maxOffset = this.defaultMessageStore.getMaxOffsetInQueue(SCHEDULE_TOPIC, queueId);
    String value = String.format("%d,%d", delayOffset, maxOffset);
    String key = String.format("%s_%d", RunningStats.scheduleMessageOffset.name(), next.getKey());
    stats.put(key, value);
  }
}
origin: alibaba/jstorm

public static <V> HashMap<V, Integer> multi_set(List<V> list) {
  HashMap<V, Integer> rtn = new HashMap<V, Integer>();
  for (V v : list) {
    int cnt = 1;
    if (rtn.containsKey(v)) {
      cnt += rtn.get(v);
    }
    rtn.put(v, cnt);
  }
  return rtn;
}
origin: apache/hive

private static Map<String, Object> createFormats() {
 ArrayList<String> formats = new ArrayList<String>();
 formats.add(MediaType.APPLICATION_JSON);
 HashMap<String, Object> res = new HashMap<String, Object>();
 res.put("responseTypes", formats);
 return Collections.unmodifiableMap(res);
}
origin: gocd/gocd

private static Map<String, Object> sanitize(Map<String, Object> flatMap) {
  HashMap<String, Object> santizedMap = new HashMap<>();
  for (Map.Entry<String, Object> entry : flatMap.entrySet()) {
    santizedMap.put(entry.getKey().toLowerCase(), entry.getValue());
  }
  return santizedMap;
}
origin: alibaba/jstorm

public static void registerMetricsConsumer(Map conf, Class klass, Object argument, long parallelismHint) {
  HashMap m = new HashMap();
  m.put("class", klass.getCanonicalName());
  m.put("parallelism.hint", parallelismHint);
  m.put("argument", argument);
  List l = (List) conf.get(TOPOLOGY_METRICS_CONSUMER_REGISTER);
  if (l == null) {
    l = new ArrayList();
  }
  l.add(m);
  conf.put(TOPOLOGY_METRICS_CONSUMER_REGISTER, l);
}
origin: apache/incubator-dubbo

/**
 * <code><pre>
 * type ::= string
 *      ::= int
 * </code></pre>
 */
private void writeType(String type)
    throws IOException {
  flushIfFull();
  int len = type.length();
  if (len == 0) {
    throw new IllegalArgumentException("empty type is not allowed");
  }
  if (_typeRefs == null)
    _typeRefs = new HashMap();
  Integer typeRefV = (Integer) _typeRefs.get(type);
  if (typeRefV != null) {
    int typeRef = typeRefV.intValue();
    writeInt(typeRef);
  } else {
    _typeRefs.put(type, Integer.valueOf(_typeRefs.size()));
    writeString(type);
  }
}
origin: libgdx/libgdx

public final float[] getFloatArray(int argLength) {
 if (!afloats.containsKey(argLength)) {
  afloats.put(argLength, new float[argLength]);
 }
 assert (afloats.get(argLength).length == argLength) : "Array not built with correct length";
 return afloats.get(argLength);
}
java.utilHashMapput

Javadoc

Maps the specified key to the specified value.

Popular methods of HashMap

  • <init>
    Constructs a new HashMap instance containing the mappings from the specified map.
  • 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
  • clone
    Returns a shallow copy of this map.
  • putAll,
  • clone,
  • toString,
  • containsValue,
  • equals,
  • hashCode,
  • computeIfAbsent,
  • getOrDefault,
  • forEach

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
  • putExtra (Intent)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Best IntelliJ plugins
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