Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Why doesn't ArrayDeque implement the List interface?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Joe Gottman, post: 3814942"] I think that we have a philosophical difference here. You think that an ArrayDeque should ONLY be used as a queue. I think that it should be usable as a queue, and for whatever other uses a coder desires, as long as those uses don't make it less efficient when used as a Queue. Note that an ArrayList can be used as either a List or a Queue, even though it is has linear complexity on its get() method. As it is currently implemented, ArrayDeque could be given a constant-complexity get() method. I find it annoying that in my use-case (a data structure with allowing indexing everywhere and insertions and deletions at the ends) the standard demands I either use a highly inefficient class or write my own. This is not an uncommon use case; see for example the C++ deque class, which has precisely these semantics. If you want to use an ArrayDeque but only want users to use it as a Deque, you can just write code like Deque<String> myDeque = new ArrayDeque<String>(); This will ensure that users of your code not misuse your ArrayDeque, while allowing others to use their own ArrayDeques as they see fit. Joe Gottman [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Why doesn't ArrayDeque implement the List interface?
Top