Sequenced Collections - Deep Dive with the Expert
summary
JDK 21 (JEP 431) adds three interfaces—SequencedCollection, SequencedSet, SequencedMap—that guarantee encounter order and supply addFirst/addLast, getFirst/getLast, removeFirst/removeLast plus a reversed view and reversed.stream. Demos show reverse views are live (no copying), getLast replaces size-1 indexing, LinkedHashSet/LinkedHashMap now let existing entries move to front or back by addFirst/addLast, and reverse streaming replaces messy ListIterator-to-Spliterator hacks with a simple reversed.stream call.
AI-written summary · about
chapters (16)
- 0:00Intro
- 0:21Collection Framework Overview
- 1:38Choosing the Right Collection
- 8:33JEP 431 - Sequenced Collections
- 10:10Collection Interface Hierarchy Evolution
- 11:45SequencedCollection Interface
- 13:48SequencedSet Interface
- 14:15SequencedMap Interface
- 15:57Removing First and Last Elements
- 18:26Iterating in Reverse
- 21:22Streaming in Reverse
- 22:45Using SequencedCollection in APIs
- 24:47Rehabilitation of LinkedHashSet & LinkedHashMap
- 26:36Demos
- 32:58Design Rationals
- 42:14Summary & Future Directions








