public void remove() { if (last == null) { throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID); } if (parent.modCount != expectedModCount) { throw new ConcurrentModificationException(); } parent.remove(last.getKey()); last = null; expectedModCount = parent.modCount; }
/** * Gets the last key in the map, which is the most recently inserted. * * @return the most recently inserted key */ @Override public K lastKey() { if (size == 0) { throw new NoSuchElementException("Map is empty"); } return header.before.getKey(); }
/** * Gets the first key in the map, which is the first inserted. * * @return the eldest key */ @Override public K firstKey() { if (size == 0) { throw new NoSuchElementException("Map is empty"); } return header.after.getKey(); }
@Override public V list(final String afterObjectId, final Collection<V> outputBuffer, final int limit) { if(isEmpty()) { return null; } LinkEntry<K, V> nextEntry = getEntry(afterObjectId); for(int i = 0; i < limit; i++) { if(nextEntry == null) { nextEntry = getEntry(firstKey()); } else { nextEntry = entryAfter(nextEntry); } if(nextEntry == null || nextEntry.getKey() == null) { break; } outputBuffer.add(nextEntry.getValue()); } return (nextEntry == null || nextEntry.getKey() == null) ? null : nextEntry.getValue(); }
@Override protected boolean removeLRU(LinkEntry<ByteArrayWrapper, V> entry) { cacheRemoved(entry.getKey().getData(), entry.getValue()); return super.removeLRU(entry); } }));
@Override protected boolean removeLRU(LinkEntry<Key, Value> entry) { cacheRemoved(entry.getKey(), entry.getValue()); return super.removeLRU(entry); } });
@Override public K next() { return super.nextEntry().getKey(); }
@Override public K getKey() { final LinkEntry<K, V> current = currentEntry(); if (current == null) { throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); } return current.getKey(); }
/** * Gets the key at the specified index. * * @param index the index to retrieve * @return the key at the specified index * @throws IndexOutOfBoundsException if the index is invalid */ public K get(final int index) { return getEntry(index).getKey(); }
@Override public K previous() { return super.previousEntry().getKey(); }
@Override protected boolean removeLRU(LinkEntry<ByteArrayWrapper, V> entry) { cacheRemoved(entry.getKey().getData(), entry.getValue()); return super.removeLRU(entry); } }));
@Override public K previous() { return super.previousEntry().getKey(); } }
@Override public String toString() { if (last != null) { return "Iterator[" + last.getKey() + "=" + last.getValue() + "]"; } return "Iterator[]"; } }
/** * Gets the previous key in sequence. * * @param key the key to get before * @return the previous key */ @Override public K previousKey(final Object key) { final LinkEntry<K, V> entry = getEntry(key); return entry == null || entry.before == header ? null : entry.before.getKey(); }
/** * Gets the next key in sequence. * * @param key the key to get after * @return the next key */ @Override public K nextKey(final Object key) { final LinkEntry<K, V> entry = getEntry(key); return entry == null || entry.after == header ? null : entry.after.getKey(); }
@Override public K next() { return super.nextEntry().getKey(); }
@Override protected boolean removeLRU(LinkEntry<Key, Value> entry) { cacheRemoved(entry.getKey(), entry.getValue()); return super.removeLRU(entry); } });