@Test public void testPut() { SafeIterableMap<Integer, Integer> map = from(1, 2, 3, 4).to(10, 20, 30, 40); assertThat(map.putIfAbsent(5, 10), is((Integer) null)); assertThat(map, is(from(1, 2, 3, 4, 5).to(10, 20, 30, 40, 10))); }
protected Entry<K, V> put(@NonNull K key, @NonNull V v) { Entry<K, V> newEntry = new Entry<>(key, v); mSize++; if (mEnd == null) { mStart = newEntry; mEnd = mStart; return newEntry; } mEnd.mNext = newEntry; newEntry.mPrevious = mEnd; mEnd = newEntry; return newEntry; }
SafeIterableMap implements Iterable<Map.Entry<K, V>> { protected Entry<K, V> put(@NonNull K key, @NonNull V v) { Entry<K, V> newEntry = new Entry<>(key, v); mSize++; if (mEnd == null) { mStart = newEntry; mEnd = mStart; return newEntry; } mEnd.mNext = newEntry; newEntry.mPrevious = mEnd; mEnd = newEntry; return newEntry; } }
SafeIterableMap implements Iterable<Map.Entry<K, V>> { protected Entry<K, V> put(@NonNull K key, @NonNull V v) { Entry<K, V> newEntry = new Entry<>(key, v); mSize++; if (mEnd == null) { mStart = newEntry; mEnd = mStart; return newEntry; } mEnd.mNext = newEntry; newEntry.mPrevious = mEnd; mEnd = newEntry; return newEntry; }  }
SafeIterableMap implements Iterable<Map.Entry<K, V>> { protected Entry<K, V> put(@NonNull K key, @NonNull V v) { Entry<K, V> newEntry = new Entry<>(key, v); mSize++; if (mEnd == null) { mStart = newEntry; mEnd = mStart; return newEntry; } mEnd.mNext = newEntry; newEntry.mPrevious = mEnd; mEnd = newEntry; return newEntry; }  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>> { protected Entry<K, V> put(@NonNull K key, @NonNull V v) { Entry<K, V> newEntry = new Entry<>(key, v); mSize++; if (mEnd == null) { mStart = newEntry; mEnd = mStart; return newEntry; } mEnd.mNext = newEntry; newEntry.mPrevious = mEnd; mEnd = newEntry; return newEntry; }  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();  }