Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37957

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

Newsgroups comp.lang.java.programmer
Date 2018-01-18 06:09 -0800
References <Zjkrl.760$5Z3.432@en-nntp-05.dc1.easynews.com>
Message-ID <2b73f760-3154-4de3-a2ee-e16380b53637@googlegroups.com> (permalink)
Subject Re: Why doesn't ArrayDeque implement the List interface?
From iamsqq@gmail.com

Show all headers | View raw


On Wednesday, March 4, 2009 at 8:55:14 AM UTC+8, Joe Gottman wrote:
> 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.  Why is this?  My use case 
> isn't unusual; it's the same as the C++ deque template.  It's especially 
> galling in that it would be possible to implement a get() member 
> function with constant time complexity in ArrayDeque, but the LinkedList 
> class, which does implement the List() interface, requires linear time 
> to perform get().  It seems backward to me that Java mandates the less 
> efficient data structure for my use case.
> 
> Joe Gottman

I just noticed that ArrayList and LinkedList are added in Java 1.2, while ArrayDeque is added in Java 6. Maybe the team think it is better for the new implementation ArrayDeque to be only for Deque, and leaving ArrayList for List.

Hogan Shi

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Why doesn't ArrayDeque implement the List interface? iamsqq@gmail.com - 2018-01-18 06:09 -0800
  Re: Why doesn't ArrayDeque implement the List interface? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2018-01-19 20:43 +0100

csiph-web