RFR: 8143850: Add indexed get() and set() methods to ArrayDeque

ExE Boss duke at openjdk.org
Tue May 13 15:22:27 UTC 2025


On Mon, 12 May 2025 18:24:27 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

> Because it is backed by an array, the `ArrayDeque` class has the ability to get and replace any element in the list (accessed by index) in constant time. However, this capability is not exposed in the API.
> 
> Please review this PR which adds the following two new methods to `ArrayDeque`:
> * `public E get(int index)`
> * `public E set(int index, E element)`

src/java.base/share/classes/java/util/ArrayDeque.java line 360:

> 358:      *
> 359:      * @param index index of the element to return
> 360:      * @return the element at the specified position in this deque

This can use the inline form of `@return`:
Suggestion:

     * {@return the element at the specified position in this deque}
     *
     * @param index index of the element to return

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25189#discussion_r2086299413


More information about the core-libs-dev mailing list