<div dir="ltr"><div>I was wondering for the n'th time why <span style="font-family:monospace">ArrayDeque</span> does not have <span style="font-family:monospace">get(int)</span> and <span style="font-family:monospace">set(int, E)</span> methods and eventually came across <a href="https://bugs.openjdk.org/browse/JDK-8143850">JDK-8143850</a> which was created 10 years ago...</div><div><br></div><div>This comment exactly describes my own experience:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">People write code, they need an "addFirst" or "removeLast" type method.
Especially for "removeLast" they find that for List this is the rather
wordy "list.remove(list.size() - 1);" with that ugly -1 constant. So
they try an ArrayDeque, and are happy that these methods exist there and
show the intent clearly... only to find a few minutes later that
ArrayDeque doesn't have a get by index method, even though the structure
can support that trivially in O(1) time -- people really expect it to
be there, as an queue backed by an array almost implies it. I'm pretty
sure that it is the 3rd or 4th time I tried using an ArrayDeque over the
past few years only to realize (again) that this method is missing.</blockquote><div><br></div><div>I would like to offer to do the following:</div><div><ul><li>Change the title of this bug from "retrofit ArrayDeque to implement List" to "Add indexed get() and set() methods to ArrayDeque"</li></ul></div><div><ul><li>Propose a corresponding PR and CSR to add <span style="font-family:monospace">get(int)</span> and <span style="font-family:monospace">set(int, E)</span> methods to <span style="font-family:monospace">ArrayDeque</span></li></ul></div><div>But first I want to check with this list first to see if there are any objections?</div><div><br></div><div>Thanks,</div><div>-Archie</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Archie L. Cobbs<br></div></div>