Re: Why doesn't ArrayDeque implement the List interface?



Hi Joe,

"Joe Gottman" <jgottman@xxxxxxxxxxxxxxx> wrote in message
[snip]
I thought that ArrayDeque was the obvious solution, but I was surprised to
find that it doesn't implement the List interface. Why is this?
The List interface includes a few methods that would break the Queue or
Dequeue semantics and invariants i.e. these List methods do not belong to
a Queue interface e.g.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html#get(int)
http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html#add(int,%20E)
http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html#remove(java.lang.Object)

HTH,
regards,
Giovanni


.



Relevant Pages

  • Why doesnt ArrayDeque implement the List interface?
    ... I have an application where I need to access the elements of a container by index and add and remove elements at either end. ... I thought that ArrayDeque was the obvious solution, but I was surprised to find that it doesn't implement the List interface. ... It's especially galling in that it would be possible to implement a getmember function with constant time complexity in ArrayDeque, but the LinkedList class, which does implement the Listinterface, requires linear time to perform get. ...
    (comp.lang.java.programmer)
  • Re: Why doesnt ArrayDeque implement the List interface?
    ... Mark Space wrote: ... container by index and add and remove elements at either end. ... I thought that ArrayDeque was the obvious solution, but I was surprised to find that it doesn't implement the List interface. ...
    (comp.lang.java.programmer)
  • Re: Why doesnt ArrayDeque implement the List interface?
    ... The List interface includes a few methods that would break the Queue ... or Dequeue semantics and invariants i.e. these List methods do not ... Note that ArrayDeque does support the last of these (and I don't see ...
    (comp.lang.java.programmer)
  • Re: Why doesnt ArrayDeque implement the List interface?
    ... Joe Gottman wrote: ... container by index and add and remove elements at either end. ... I thought that ArrayDeque was the obvious solution, but I was surprised to find that it doesn't implement the List interface. ...
    (comp.lang.java.programmer)