@Test public void testRemoveSole() { SafeIterableMap<Integer, Integer> map = from(1).to(261); assertThat(map.remove(1), is(261)); assertThat(map, is(new SafeIterableMap<Integer, Integer>())); }
public V remove(@NonNull K key) { Entry<K, V> toRemove = get(key); if (toRemove == null) { return null; } mSize--; if (!mIterators.isEmpty()) { for (SupportRemove<K, V> iter : mIterators.keySet()) { iter.supportRemove(toRemove); } } if (toRemove.mPrevious != null) { toRemove.mPrevious.mNext = toRemove.mNext; } else { mStart = toRemove.mNext; } if (toRemove.mNext != null) { toRemove.mNext.mPrevious = toRemove.mPrevious; } else { mEnd = toRemove.mPrevious; } toRemove.mNext = null; toRemove.mPrevious = null; return toRemove.mValue; }
SafeIterableMap implements Iterable<Map.Entry<K, V>> { public V remove(@NonNull K key) { Entry<K, V> toRemove = get(key); if (toRemove == null) { return null; } mSize--; if (!mIterators.isEmpty()) { for (SupportRemove<K, V> iter : mIterators.keySet()) { iter.supportRemove(toRemove); } } if (toRemove.mPrevious != null) { toRemove.mPrevious.mNext = toRemove.mNext; } else { mStart = toRemove.mNext; } if (toRemove.mNext != null) { toRemove.mNext.mPrevious = toRemove.mPrevious; } else { mEnd = toRemove.mPrevious; } toRemove.mNext = null; toRemove.mPrevious = null; return toRemove.mValue; } }
SafeIterableMap implements Iterable<Map.Entry<K, V>> { public V remove(@NonNull K key) { Entry<K, V> toRemove = get(key); if (toRemove == null) { return null; } mSize--; if (!mIterators.isEmpty()) { for (SupportRemove<K, V> iter : mIterators.keySet()) { iter.supportRemove(toRemove); } } if (toRemove.mPrevious != null) { toRemove.mPrevious.mNext = toRemove.mNext; } else { mStart = toRemove.mNext; } if (toRemove.mNext != null) { toRemove.mNext.mPrevious = toRemove.mPrevious; } else { mEnd = toRemove.mPrevious; } toRemove.mNext = null; toRemove.mPrevious = null; return toRemove.mValue; }  }
SafeIterableMap implements Iterable<Map.Entry<K, V>> { public V remove(@NonNull K key) { Entry<K, V> toRemove = get(key); if (toRemove == null) { return null; } mSize--; if (!mIterators.isEmpty()) { for (SupportRemove<K, V> iter : mIterators.keySet()) { iter.supportRemove(toRemove); } } if (toRemove.mPrevious != null) { toRemove.mPrevious.mNext = toRemove.mNext; } else { mStart = toRemove.mNext; } if (toRemove.mNext != null) { toRemove.mNext.mPrevious = toRemove.mPrevious; } else { mEnd = toRemove.mPrevious; } toRemove.mNext = null; toRemove.mPrevious = null; return toRemove.mValue; }  V putIfAbsent(@NonNull K key, @NonNull V v); V remove(@NonNull K key); int size(); @NonNull @Override Iterator<Map.Entry<K, V>> iterator(); Iterator<Map.Entry<K, V>> descendingIterator(); IteratorWithAdditions iteratorWithAdditions(); Map.Entry<K, V> eldest(); Map.Entry<K, V> newest(); @Override boolean equals(Object obj); @Override String toString(); }
SafeIterableMap implements Iterable<Map.Entry<K, V>> { public V remove(@NonNull K key) { Entry<K, V> toRemove = get(key); if (toRemove == null) { return null; } mSize--; if (!mIterators.isEmpty()) { for (SupportRemove<K, V> iter : mIterators.keySet()) { iter.supportRemove(toRemove); } } if (toRemove.mPrevious != null) { toRemove.mPrevious.mNext = toRemove.mNext; } else { mStart = toRemove.mNext; } if (toRemove.mNext != null) { toRemove.mNext.mPrevious = toRemove.mPrevious; } else { mEnd = toRemove.mPrevious; } toRemove.mNext = null; toRemove.mPrevious = null; return toRemove.mValue; }  V putIfAbsent(@NonNull K key, @NonNull V v); V remove(@NonNull K key); int size(); @NonNull @Override Iterator<Map.Entry<K, V>> iterator(); Iterator<Map.Entry<K, V>> descendingIterator(); IteratorWithAdditions iteratorWithAdditions(); Map.Entry<K, V> eldest(); Map.Entry<K, V> newest(); @Override boolean equals(Object obj); @Override String toString();  }