/** * Gets the last (and only) key in the map. * * @return the key */ @Override public K lastKey() { return getKey(); }
/** * Gets the first (and only) key in the map. * * @return the key */ @Override public K firstKey() { return getKey(); }
@Override public K previous() { if (hasNext == true) { throw new NoSuchElementException(AbstractHashedMap.NO_PREVIOUS_ENTRY); } hasNext = true; return parent.getKey(); }
@Override public K next() { if (hasNext == false) { throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY); } hasNext = false; canGetSet = true; return parent.getKey(); }
@Override public K getKey() { if (canGetSet == false) { throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); } return parent.getKey(); }
/** * Gets the entrySet view of the map. * Changes made via <code>setValue</code> affect this map. * To simply iterate through the entries, use {@link #mapIterator()}. * * @return the entrySet view */ @Override public Set<Map.Entry<K, V>> entrySet() { final Map.Entry<K, V> entry = new TiedMapEntry<>(this, getKey()); return Collections.singleton(entry); }
/** * Gets the map as a String. * * @return a string version of the map */ @Override public String toString() { return new StringBuilder(128) .append('{') .append(getKey() == this ? "(this Map)" : getKey()) .append('=') .append(getValue() == this ? "(this Map)" : getValue()) .append('}') .toString(); }