Menu
Java collections framework needs sequences, OpenJDK proposal says

Java collections framework needs sequences, OpenJDK proposal says

Proposal for enhancing standard Java would define interfaces for sequenced collections, sequenced sets, and sequenced maps.

Credit: Dreamstime

Addressing an issue that has been a source of ongoing complaints, Java could add sequenced collections, sequenced sets, and sequenced maps, anchored by interfaces to represent collections with a defined encounter order.

A proposal pending in the OpenJDK community would define interfaces for sequenced collections, sequenced sets, and sequenced maps, and retrofit them into the existing collections type hierarchy.

Motivating the plan are two gaps in Java’s collections framework, the language’s architecture for representing and manipulating collections: It lacks a collection type that represents a sequence of elements with a defined encounter order, and it lacks a uniform set of operations that apply across such operations.

These gaps, the proposal states, have been a repeated source of complaints and problems. For example, although List and Deque both define an encounter order, their common supertype, Collection, does not.

With the sequenced collections proposal, all of the new methods declared in the new interfaces have default implementations. Sequenced collections would be added to the standard edition of Java. The earliest it could arrive would be with JDK 20, due next March, with JDK 19 having just arrived last month as part of standard Java’s six-month release cadence.

A sequenced collection is defined as a Collection whose elements have a defined encounter order. Such a collection has first and last elements, and elements between them have successors and predecessors. Common operations are supported at either end of a sequenced collection.

Processing of elements from first to last and from last to first are supported. The proposal marks an incremental evolution of the ReversibleCollections proposal from 2021, to add a ReversibleCollections interface to the collections framework.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags javaOpenJDK

Events

EDGE 2023

EDGE is the leading technology conference for business leaders in Australia and New Zealand, built on the foundations of collaboration, education and advancement.

WIICTA 2023

ARN has celebrated gender diversity and recognised female excellence across the Australian tech channel since first launching WIICTA in 2012, acknowledging the achievements of a talented group of female front runners who have become influential figures across the local industry.

ARN Innovation Awards 2023

Innovation Awards is the market-leading awards program for celebrating ecosystem innovation and excellence across the technology sector in Australia.

Show Comments