@Test public void forEachProcedure() { final IntLinkedHashMap<String> tested = new IntLinkedHashMap<>(); for (int i = 0; i < 100000; ++i) { tested.put(i, Integer.toString(i)); } final int[] ii = {0}; tested.forEachKey(object -> { ii[0]++; return true; }); tested.forEachValue(object -> { ii[0]++; return true; }); Assert.assertEquals(tested.size() * 2, ii[0]); ii[0] = 0; tested.forEachKey(object -> { ii[0]++; return object > 99500; }); tested.forEachValue(object -> { ii[0]++; return true; }); Assert.assertEquals(tested.size() + 500, ii[0]); }
public V put(final int key, final V value) { final Entry<V>[] table = this.table; final int index = HashUtil.indexFor(key, table.length, mask); for (Entry<V> e = table[index]; e != null; e = e.hashNext) { if (e.key == key) { moveToTop(e); return e.setValue(value); } } final Entry<V> e = new Entry<>(key, value); e.hashNext = table[index]; table[index] = e; final Entry<V> top = this.top; e.next = top; if (top != null) { top.previous = e; } else { back = e; } this.top = e; _size += 1; if (removeEldestEntry(back)) { remove(back.key); } else if (_size > capacity) { rehash(HashUtil.nextCapacity(capacity)); } return null; }
IntLinkedHashMap extends AbstractHashMap<Integer, V> { public V put(final int key, final V value) { final Entry<V>[] table = this.table; final int index = HashUtil.indexFor(key, table.length, mask); for (Entry<V> e = table[index]; e != null; e = e.hashNext) { if (e.key == key) { moveToTop(e); return e.setValue(value); } } final Entry<V> e = new Entry<>(key, value); e.hashNext = table[index]; table[index] = e; final Entry<V> top = this.top; e.next = top; if (top != null) { top.previous = e; } else { back = e; } this.top = e; _size += 1; if (removeEldestEntry(back)) { remove(back.key); } else if (_size > capacity) { rehash(HashUtil.nextCapacity(capacity)); } return null; } }
IntLinkedHashMap extends AbstractHashMap<Integer, V> { public V put(final int key, final V value) { final Entry<V>[] table = this.table; final int index = HashUtil.indexFor(key, table.length, mask); for (Entry<V> e = table[index]; e != null; e = e.hashNext) { if (e.key == key) { moveToTop(e); return e.setValue(value); } } final Entry<V> e = new Entry<>(key, value); e.hashNext = table[index]; table[index] = e; final Entry<V> top = this.top; e.next = top; if (top != null) { top.previous = e; } else { back = e; } this.top = e; _size += 1; if (removeEldestEntry(back)) { remove(back.key); } else if (_size > capacity) { rehash(HashUtil.nextCapacity(capacity)); } return null; } IntLinkedHashMap();  IntLinkedHashMap(int capacity);  IntLinkedHashMap(int capacity, float loadFactor); }
IntLinkedHashMap extends AbstractHashMap<Integer, V> { public V put(final int key, final V value) { final Entry<V>[] table = this.table; final int index = HashUtil.indexFor(key, table.length, mask); for (Entry<V> e = table[index]; e != null; e = e.hashNext) { if (e.key == key) { moveToTop(e); return e.setValue(value); } } final Entry<V> e = new Entry<>(key, value); e.hashNext = table[index]; table[index] = e; final Entry<V> top = this.top; e.next = top; if (top != null) { top.previous = e; } else { back = e; } this.top = e; _size += 1; if (removeEldestEntry(back)) { remove(back.key); } else if (_size > capacity) { rehash(HashUtil.nextCapacity(capacity)); } return null; } IntLinkedHashMap();  IntLinkedHashMap(int capacity);  IntLinkedHashMap(int capacity, float loadFactor); V get(final int key); V put(final int key, final V value); @Override V put(final Integer key, final V value); boolean containsKey(final int key); V remove(final int key); @Override V remove(Object key); }
IntLinkedHashMap extends AbstractHashMap<Integer, V> { public V put(final int key, final V value) { final Entry<V>[] table = this.table; final int index = HashUtil.indexFor(key, table.length, mask); for (Entry<V> e = table[index]; e != null; e = e.hashNext) { if (e.key == key) { moveToTop(e); return e.setValue(value); } } final Entry<V> e = new Entry<>(key, value); e.hashNext = table[index]; table[index] = e; final Entry<V> top = this.top; e.next = top; if (top != null) { top.previous = e; } else { back = e; } this.top = e; _size += 1; if (removeEldestEntry(back)) { remove(back.key); } else if (_size > capacity) { rehash(HashUtil.nextCapacity(capacity)); } return null; } IntLinkedHashMap();  IntLinkedHashMap(int capacity);  IntLinkedHashMap(int capacity, float loadFactor); V get(final int key); V put(final int key, final V value); @Override V put(final Integer key, final V value); boolean containsKey(final int key); V remove(final int key); @Override V remove(Object key);  }