Tabnine Logo
Map$Entry.getKey
Code IndexAdd Tabnine to your IDE (free)

How to use
getKey
method
in
java.util.Map$Entry

Best Java code snippets using java.util.Map$Entry.getKey (Showing top 20 results out of 223,965)

Refine searchRefine arrow

  • Map.entrySet
  • Map.Entry.getValue
  • Map.put
  • Map.get
  • Iterator.next
  • Iterator.hasNext
  • Map.size
origin: stackoverflow.com

 public static void printMap(Map mp) {
  Iterator it = mp.entrySet().iterator();
  while (it.hasNext()) {
    Map.Entry pair = (Map.Entry)it.next();
    System.out.println(pair.getKey() + " = " + pair.getValue());
    it.remove(); // avoids a ConcurrentModificationException
  }
}
origin: stackoverflow.com

 for (Map.Entry<String, Object> entry : map.entrySet()) {
  String key = entry.getKey();
  Object value = entry.getValue();
  // ...
}
origin: square/okhttp

public Challenge(String scheme, Map<String, String> authParams) {
 if (scheme == null) throw new NullPointerException("scheme == null");
 if (authParams == null) throw new NullPointerException("authParams == null");
 this.scheme = scheme;
 Map<String, String> newAuthParams = new LinkedHashMap<>();
 for (Entry<String, String> authParam : authParams.entrySet()) {
  String key = (authParam.getKey() == null) ? null : authParam.getKey().toLowerCase(US);
  newAuthParams.put(key, authParam.getValue());
 }
 this.authParams = unmodifiableMap(newAuthParams);
}
origin: apache/kafka

private void innerUpdateEndOffsets(final Map<TopicPartition, Long> newOffsets,
                  final boolean replace) {
  for (final Map.Entry<TopicPartition, Long> entry : newOffsets.entrySet()) {
    List<Long> offsets = endOffsets.get(entry.getKey());
    if (replace || offsets == null) {
      offsets = new ArrayList<>();
    }
    offsets.add(entry.getValue());
    endOffsets.put(entry.getKey(), offsets);
  }
}
origin: prestodb/presto

public Map<String, Double> getOperatorHashCollisionsAverages()
{
  return operatorHashCollisionsStats.entrySet().stream()
      .collect(toMap(
          Map.Entry::getKey,
          entry -> entry.getValue().getWeightedHashCollisions() / operatorInputStats.get(entry.getKey()).getInputPositions()));
}
origin: bumptech/glide

private Map<String, List<LazyHeaderFactory>> copyHeaders() {
 Map<String, List<LazyHeaderFactory>> result = new HashMap<>(headers.size());
 for (Map.Entry<String, List<LazyHeaderFactory>> entry : headers.entrySet()) {
  @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
  List<LazyHeaderFactory> valueCopy = new ArrayList<>(entry.getValue());
  result.put(entry.getKey(), valueCopy);
 }
 return result;
}
origin: google/guava

@CanIgnoreReturnValue
private Map<R, V> removeColumn(Object column) {
 Map<R, V> output = new LinkedHashMap<>();
 Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
 while (iterator.hasNext()) {
  Entry<R, Map<C, V>> entry = iterator.next();
  V value = entry.getValue().remove(column);
  if (value != null) {
   output.put(entry.getKey(), value);
   if (entry.getValue().isEmpty()) {
    iterator.remove();
   }
  }
 }
 return output;
}
origin: apache/zookeeper

public synchronized void purgeUnused() {
  Iterator<Map.Entry<Long, AtomicLongWithEquals>> refCountIter = referenceCounter.entrySet().iterator();
  while (refCountIter.hasNext()) {
    Map.Entry<Long, AtomicLongWithEquals> entry = refCountIter.next();
    if (entry.getValue().get() <= 0) {
      Long acl = entry.getKey();
      aclKeyMap.remove(longKeyMap.get(acl));
      longKeyMap.remove(acl);
      refCountIter.remove();
    }
  }
}
origin: google/guava

/**
 * Stores the contents of a map in an output stream, as part of serialization. It does not support
 * concurrent maps whose content may change while the method is running.
 *
 * <p>The serialized output consists of the number of entries, first key, first value, second key,
 * second value, and so on.
 */
static <K, V> void writeMap(Map<K, V> map, ObjectOutputStream stream) throws IOException {
 stream.writeInt(map.size());
 for (Map.Entry<K, V> entry : map.entrySet()) {
  stream.writeObject(entry.getKey());
  stream.writeObject(entry.getValue());
 }
}
origin: google/guava

private static <T, M extends Map<T, String>> M populate(M map, Entry<T, String>[] entries) {
 for (Entry<T, String> entry : entries) {
  map.put(entry.getKey(), entry.getValue());
 }
 return map;
}
origin: google/guava

public void testEntrySetSetValueSameValue() {
 // TODO: Investigate the extent to which, in practice, maps that support
 // put() also support Entry.setValue().
 if (!supportsPut) {
  return;
 }
 final Map<K, V> map;
 try {
  map = makePopulatedMap();
 } catch (UnsupportedOperationException e) {
  return;
 }
 Set<Entry<K, V>> entrySet = map.entrySet();
 Entry<K, V> entry = entrySet.iterator().next();
 final V oldValue = entry.getValue();
 final V returnedValue = entry.setValue(oldValue);
 assertEquals(oldValue, returnedValue);
 assertTrue(entrySet.contains(mapEntry(entry.getKey(), oldValue)));
 assertEquals(oldValue, map.get(entry.getKey()));
 assertInvariants(map);
}
origin: apache/incubator-dubbo

public static boolean mapEquals(Map<?, ?> map1, Map<?, ?> map2) {
  if (map1 == null && map2 == null) {
    return true;
  }
  if (map1 == null || map2 == null) {
    return false;
  }
  if (map1.size() != map2.size()) {
    return false;
  }
  for (Map.Entry<?, ?> entry : map1.entrySet()) {
    Object key = entry.getKey();
    Object value1 = entry.getValue();
    Object value2 = map2.get(key);
    if (!objectEquals(value1, value2)) {
      return false;
    }
  }
  return true;
}
origin: google/guava

@Override
public Iterable<Entry<K, Collection<V>>> order(List<Entry<K, Collection<V>>> insertionOrder) {
 Map<K, Collection<V>> map = new HashMap<>();
 List<Entry<K, V>> builder = new ArrayList<>();
 for (Entry<K, Collection<V>> entry : insertionOrder) {
  for (V v : entry.getValue()) {
   builder.add(mapEntry(entry.getKey(), v));
  }
  map.put(entry.getKey(), entry.getValue());
 }
 Iterable<Entry<K, V>> ordered = multimapGenerator.order(builder);
 LinkedHashMap<K, Collection<V>> orderedMap = new LinkedHashMap<>();
 for (Entry<K, V> entry : ordered) {
  orderedMap.put(entry.getKey(), map.get(entry.getKey()));
 }
 return orderedMap.entrySet();
}
origin: google/guava

 @Override
 public Entry<K, V> next() {
  if (!valueItr.hasNext()) {
   Entry<K, ? extends ImmutableCollection<V>> entry = asMapItr.next();
   currentKey = entry.getKey();
   valueItr = entry.getValue().iterator();
  }
  return Maps.immutableEntry(currentKey, valueItr.next());
 }
};
origin: google/guava

@Override
protected void expectContents(Collection<Entry<K, V>> expected) {
 // TODO: move this to invariant checks once the appropriate hook exists?
 super.expectContents(expected);
 for (Entry<K, V> entry : expected) {
  assertEquals(
    "Wrong value for key " + entry.getKey(), entry.getValue(), getMap().get(entry.getKey()));
 }
}
origin: google/guava

private void putAll(Iterable<Entry<K, V>> entries) {
 Map<K, V> map = new LinkedHashMap<>();
 for (Entry<K, V> entry : entries) {
  map.put(entry.getKey(), entry.getValue());
 }
 getMap().putAll(map);
}
origin: google/guava

 @CollectionSize.Require(absent = ZERO)
 @MapFeature.Require(SUPPORTS_REMOVE)
 public void testEntriesRemainValidAfterRemove() {
  Iterator<Entry<K, V>> iterator = multimap().entries().iterator();
  Entry<K, V> entry = iterator.next();
  K key = entry.getKey();
  V value = entry.getValue();
  multimap().removeAll(key);
  assertEquals(key, entry.getKey());
  assertEquals(value, entry.getValue());
 }
}
origin: ReactiveX/RxJava

static <T> StringBuilder allSequenceFrequency(Map<Integer, List<T>> its) {
  StringBuilder b = new StringBuilder();
  for (Map.Entry<Integer, List<T>> e : its.entrySet()) {
    if (b.length() > 0) {
      b.append(", ");
    }
    b.append(e.getKey()).append("={");
    b.append(sequenceFrequency(e.getValue()));
    b.append("}");
  }
  return b;
}
static <T> StringBuilder sequenceFrequency(Iterable<T> it) {
origin: stackoverflow.com

 Map map = new HashMap();
Iterator entries = map.entrySet().iterator();
while (entries.hasNext()) {
  Map.Entry entry = (Map.Entry) entries.next();
  Integer key = (Integer)entry.getKey();
  Integer value = (Integer)entry.getValue();
  System.out.println("Key = " + key + ", Value = " + value);
}
origin: google/guava

/** An implementation of {@link Map#putAll}. */
static <K, V> void putAllImpl(Map<K, V> self, Map<? extends K, ? extends V> map) {
 for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
  self.put(entry.getKey(), entry.getValue());
 }
}
java.utilMap$EntrygetKey

Javadoc

Returns the key.

Popular methods of Map$Entry

  • getValue
    Returns the value corresponding to this entry. If the mapping has been removed from the backing map
  • setValue
    Sets the value of this entry to the specified value, replacing any existing value.
  • equals
    Compares the specified object to this Map.Entry and returns if they are equal. To be equal, the obje
  • hashCode
    Returns an integer hash code for the receiver. Object which are equal return the same value for this
  • comparingByValue
  • comparingByKey
  • <init>

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • setScale (BigDecimal)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top plugins for Android Studio
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