java.util · java.base · since Java 21

SequencedMap

declaration
public interface SequencedMap<K, V> extends Map<K, V>

Java 21 Map with a defined encounter order: first/last entries, put-at-end, and reversed/sequenced views. Implemented by LinkedHashMap and NavigableMap.

Key methods

Map.Entry<K, V> firstEntry() / lastEntry()Ends of the encounter order (null if empty).
Map.Entry<K, V> pollFirstEntry() / pollLastEntry()Retrieve and remove an end entry.
V putFirst(K, V) / putLast(K, V)Insert or move a mapping to an end.
SequencedMap<K, V> reversed()Reverse-order VIEW of the mappings.