To run each example use: java --enable-preview --source 20 <FileName.java>
JEPs proposed to target:
- 431 - Sequenced Collections
- Sequenced Collections
- new interfaces to define a common way to iterate throught sequenced collections (list, sets and maps)
- collections type hierarchy with new interfaces
- sequenced collection:
- a sequenced collection is a collection whose elements have a defined encounter order
- sequenced collection has a first and last elements, and the elements between them have successors and predecessors
- it supports common operations at the beginning and the end of the collection, also allow iterate it forward or backward
- methods from
SequencedCollection<E>interface:reversedaddFirstaddLastgetFirstgetLastremoveFirstremoveLast
- sequenced set:
- sequenced set is a set that is sequenced collcetion that do not allow duplicate elements
- methods from
SequencedSet<E>interface:reversed
- sequenced map:
- sequenced map is a map whose entries have a defined encounter order
- methods from
SequencedMap<K,V>interface:reversedsequencedKeySetsequencedValuessequencedEntrySetputFirstputLastfirstEntrylastEntrypollFirstEntrypollLastEntry
- new methods in
Collections:unmodifiableSequencedCollectionunmodifiableSequencedSetunmodifiableSequencedMap