Esempio n. 1
0
 /** {@inheritDoc} */
 public void clear() {
   map.clear();
   if (parent != null) {
     int curRange = range();
     parent.updateParentRange(-curRange);
   }
   range = 0;
 }
Esempio n. 2
0
  /** {@inheritDoc} */
  public Set<V> remove(Object key) {
    Set<V> v = map.remove(key);
    if (v != null) range -= v.size();
    if (parent != null) {
      parent.updateParentRange(-(v.size()));
    }

    return v;
  }
Esempio n. 3
0
 /** {@inheritDoc} */
 public boolean remove(K key, V value) {
   Set<V> values = map.get(key);
   boolean removed = values.remove(value);
   if (removed) {
     range--;
     if (parent != null) {
       parent.updateParentRange(-1);
     }
   }
   // if this was the last value mapping for this key, remove the
   // key altogether
   if (values.size() == 0) map.remove(key);
   return removed;
 }
Esempio n. 4
0
 /** {@inheritDoc} */
 public boolean put(K key, V value) {
   Set<V> values = map.get(key);
   if (values == null) {
     values = new HashSet<V>();
     map.put(key, values);
   }
   boolean added = values.add(value);
   if (added) {
     range++;
     if (parent != null) {
       parent.updateParentRange(1);
     }
   }
   return added;
 }
Esempio n. 5
0
 /** Recursively updates the range value for the the super-map of this sub-map if it exists. */
 private void updateParentRange(int valueDifference) {
   range += valueDifference;
   if (parent != null) {
     parent.updateParentRange(valueDifference);
   }
 }