Tabnine Logo
Map.remove
Code IndexAdd Tabnine to your IDE (free)

How to use
remove
method
in
java.util.Map

Best Java code snippets using java.util.Map.remove (Showing top 20 results out of 137,142)

Refine searchRefine arrow

  • Map.get
  • Map.put
  • Map.containsKey
  • Map.Entry.getKey
  • Map.Entry.getValue
  • Map.entrySet
  • Map.keySet
origin: spring-projects/spring-framework

public void setAttribute(String name, Object value) {
  if (value != null) {
    this.attributes.put(name, value);
  }
  else {
    this.attributes.remove(name);
  }
}
origin: google/guava

@Override
public Set<V> removeAll(Object key) {
 Set<V> values = new HashSet<V>(2);
 if (!map.containsKey(key)) {
  return values;
 }
 values.add(map.remove(key));
 return values;
}
origin: apache/kafka

private boolean isMuted(TopicPartition tp, long now) {
  boolean result = muted.containsKey(tp) && muted.get(tp) > now;
  if (!result)
    muted.remove(tp);
  return result;
}
origin: redisson/redisson

@Override
public V put(K key, V value) {
  if (keyValueMap.containsKey(key)) {
    valueKeyMap.remove(keyValueMap.get(key));
  }
  valueKeyMap.put(value, key);
  return keyValueMap.put(key, value);
}
origin: apache/incubator-dubbo

  @Override
  public void run() {
    try {
      CompletableFuture<Monitor> completableFuture = AbstractMonitorFactory.FUTURES.get(key);
      AbstractMonitorFactory.MONITORS.put(key, completableFuture.get());
      AbstractMonitorFactory.FUTURES.remove(key);
    } catch (InterruptedException e) {
      logger.warn("Thread was interrupted unexpectedly, monitor will never be got.");
      AbstractMonitorFactory.FUTURES.remove(key);
    } catch (ExecutionException e) {
      logger.warn("Create monitor failed, monitor data will not be collected until you fix this problem. ", e);
    }
  }
}
origin: apache/storm

private static Set<WorkerSlot> badSlots(Map<WorkerSlot, List<ExecutorDetails>> existingSlots, int numExecutors, int numWorkers) {
  if (numWorkers != 0) {
    Map<Integer, Integer> distribution = Utils.integerDivided(numExecutors, numWorkers);
    Set<WorkerSlot> slots = new HashSet<WorkerSlot>();
    for (Entry<WorkerSlot, List<ExecutorDetails>> entry : existingSlots.entrySet()) {
      Integer executorCount = entry.getValue().size();
      Integer workerCount = distribution.get(executorCount);
      if (workerCount != null && workerCount > 0) {
        slots.add(entry.getKey());
        workerCount--;
        distribution.put(executorCount, workerCount);
      }
    }
    for (WorkerSlot slot : slots) {
      existingSlots.remove(slot);
    }
    return existingSlots.keySet();
  }
  return null;
}
origin: spring-projects/spring-framework

/**
 * Add the given singleton factory for building the specified singleton
 * if necessary.
 * <p>To be called for eager registration of singletons, e.g. to be able to
 * resolve circular references.
 * @param beanName the name of the bean
 * @param singletonFactory the factory for the singleton object
 */
protected void addSingletonFactory(String beanName, ObjectFactory<?> singletonFactory) {
  Assert.notNull(singletonFactory, "Singleton factory must not be null");
  synchronized (this.singletonObjects) {
    if (!this.singletonObjects.containsKey(beanName)) {
      this.singletonFactories.put(beanName, singletonFactory);
      this.earlySingletonObjects.remove(beanName);
      this.registeredSingletons.add(beanName);
    }
  }
}
origin: twosigma/beakerx

 public void dropAll(final String shellId) {
  List<String> keys = new ArrayList<String>(_shellToId.keySet());
  for (String s : keys) {
   if (_shellToId.get(s).equals(shellId)) {
    _shellToId.remove(s);
    _forms.remove(s);
   }
  }
 }
}
origin: google/guava

public void testRemove() {
 final Map<K, V> map;
 final K keyToRemove;
 try {
  map = makePopulatedMap();
 } catch (UnsupportedOperationException e) {
  return;
 }
 keyToRemove = map.keySet().iterator().next();
 if (supportsRemove) {
  int initialSize = map.size();
  V expectedValue = map.get(keyToRemove);
  V oldValue = map.remove(keyToRemove);
  assertEquals(expectedValue, oldValue);
  assertFalse(map.containsKey(keyToRemove));
  assertEquals(initialSize - 1, map.size());
 } else {
  try {
   map.remove(keyToRemove);
   fail("Expected UnsupportedOperationException.");
  } catch (UnsupportedOperationException expected) {
  }
 }
 assertInvariants(map);
}
origin: skylot/jadx

public void remove(IAttribute attr) {
  AType<? extends IAttribute> type = attr.getType();
  IAttribute a = attributes.get(type);
  if (a == attr) {
    attributes.remove(type);
  }
}
origin: org.testng/testng

@Override
public void removeResult(ITestNGMethod m) {
 for (Entry<ITestResult, ITestNGMethod> entry : m_map.entrySet()) {
  if (entry.getValue().equals(m)) {
   m_map.remove(entry.getKey());
   return;
  }
 }
}
origin: google/guava

private static <K, V> void doDifference(
  Map<? extends K, ? extends V> left,
  Map<? extends K, ? extends V> right,
  Equivalence<? super V> valueEquivalence,
  Map<K, V> onlyOnLeft,
  Map<K, V> onlyOnRight,
  Map<K, V> onBoth,
  Map<K, MapDifference.ValueDifference<V>> differences) {
 for (Entry<? extends K, ? extends V> entry : left.entrySet()) {
  K leftKey = entry.getKey();
  V leftValue = entry.getValue();
  if (right.containsKey(leftKey)) {
   V rightValue = onlyOnRight.remove(leftKey);
   if (valueEquivalence.equivalent(leftValue, rightValue)) {
    onBoth.put(leftKey, leftValue);
   } else {
    differences.put(leftKey, ValueDifferenceImpl.create(leftValue, rightValue));
   }
  } else {
   onlyOnLeft.put(leftKey, leftValue);
  }
 }
}
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: ctripcorp/apollo

/**
 * 合并用户对namespace的修改
 */
private Map<String, String> mergeOverriddenProperties(String namespace, Map<String, String> configurations) {
 if (addedOrModifiedPropertiesOfNamespace.containsKey(namespace)) {
  configurations.putAll(addedOrModifiedPropertiesOfNamespace.get(namespace));
 }
 if (deletedKeysOfNamespace.containsKey(namespace)) {
  for (String k : deletedKeysOfNamespace.get(namespace)) {
   configurations.remove(k);
  }
 }
 return configurations;
}
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: google/guava

public void testStandardEntrySet() throws InvocationTargetException {
 @SuppressWarnings("unchecked")
 final Map<String, Boolean> map = mock(Map.class);
 Map<String, Boolean> forward =
   new ForwardingMap<String, Boolean>() {
    @Override
    protected Map<String, Boolean> delegate() {
     return map;
    }
    @Override
    public Set<Entry<String, Boolean>> entrySet() {
     return new StandardEntrySet() {
      @Override
      public Iterator<Entry<String, Boolean>> iterator() {
       return Iterators.emptyIterator();
      }
     };
    }
   };
 callAllPublicMethods(new TypeToken<Set<Entry<String, Boolean>>>() {}, forward.entrySet());
 // These are the methods specified by StandardEntrySet
 verify(map, atLeast(0)).clear();
 verify(map, atLeast(0)).containsKey(anyObject());
 verify(map, atLeast(0)).get(anyObject());
 verify(map, atLeast(0)).isEmpty();
 verify(map, atLeast(0)).remove(anyObject());
 verify(map, atLeast(0)).size();
 verifyNoMoreInteractions(map);
}
origin: google/guava

public void testStandardKeySet() throws InvocationTargetException {
 @SuppressWarnings("unchecked")
 final Map<String, Boolean> map = mock(Map.class);
 Map<String, Boolean> forward =
   new ForwardingMap<String, Boolean>() {
    @Override
    protected Map<String, Boolean> delegate() {
     return map;
    }
    @Override
    public Set<String> keySet() {
     return new StandardKeySet();
    }
   };
 callAllPublicMethods(new TypeToken<Set<String>>() {}, forward.keySet());
 // These are the methods specified by StandardKeySet
 verify(map, atLeast(0)).clear();
 verify(map, atLeast(0)).containsKey(anyObject());
 verify(map, atLeast(0)).isEmpty();
 verify(map, atLeast(0)).remove(anyObject());
 verify(map, atLeast(0)).size();
 verify(map, atLeast(0)).entrySet();
 verifyNoMoreInteractions(map);
}
origin: redisson/redisson

@Override
public V put(K key, V value) {
  if (keyValueMap.containsKey(key)) {
    valueKeyMap.remove(keyValueMap.get(key));
  }
  valueKeyMap.put(value, key);
  return keyValueMap.put(key, value);
}
origin: apache/incubator-dubbo

  @Override
  public void run() {
    try {
      CompletableFuture<Monitor> completableFuture = AbstractMonitorFactory.FUTURES.get(key);
      AbstractMonitorFactory.MONITORS.put(key, completableFuture.get());
      AbstractMonitorFactory.FUTURES.remove(key);
    } catch (InterruptedException e) {
      logger.warn("Thread was interrupted unexpectedly, monitor will never be got.");
      AbstractMonitorFactory.FUTURES.remove(key);
    } catch (ExecutionException e) {
      logger.warn("Create monitor failed, monitor data will not be collected until you fix this problem. ", e);
    }
  }
}
origin: robolectric/robolectric

@SuppressWarnings("ReferenceEquality")
public Set<String> getInvalidatedClasses(ShadowMap previous) {
 if (this == previous && shadowPickers.isEmpty()) return Collections.emptySet();
 Map<String, ShadowInfo> invalidated = new HashMap<>(overriddenShadows);
 for (Map.Entry<String, ShadowInfo> entry : previous.overriddenShadows.entrySet()) {
  String className = entry.getKey();
  ShadowInfo previousConfig = entry.getValue();
  ShadowInfo currentConfig = invalidated.get(className);
  if (currentConfig == null) {
   invalidated.put(className, previousConfig);
  } else if (previousConfig.equals(currentConfig)) {
   invalidated.remove(className);
  }
 }
 HashSet<String> classNames = new HashSet<>(invalidated.keySet());
 classNames.addAll(shadowPickers.keySet());
 return classNames;
}
java.utilMapremove

Javadoc

Removes a mapping with the specified key from this Map.

Popular methods of Map

  • put
    Maps the specified key to the specified value.
  • get
  • entrySet
    Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes t
  • 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
  • values
    Returns a Collection view of the values contained in this map. The collection is backed by the map,
  • size
    Returns the number of mappings in this Map.
  • isEmpty
    Returns true if this map contains no key-value mappings.
  • clear
    Removes all elements from this Map, leaving it empty.
  • putAll
    Copies all of the mappings from the specified map to this map (optional operation). The effect of th
  • forEach
  • equals
    Compares the argument to the receiver, and returns true if the specified object is a Map and both Ma
  • forEach,
  • equals,
  • computeIfAbsent,
  • hashCode,
  • getOrDefault,
  • containsValue,
  • putIfAbsent,
  • compute,
  • merge

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • putExtra (Intent)
  • addToBackStack (FragmentTransaction)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JButton (javax.swing)
  • 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