Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Does Java 1.5 have circular linkedlist implementation? (http://www.velocityreviews.com/forums/t141844-does-java-1-5-have-circular-linkedlist-implementation.html)

Sharp 03-12-2005 05:50 AM

Does Java 1.5 have circular linkedlist implementation?
 
Hi
Does Java 1.5 have circular linkedlist implementation?
if not, where can I find a 3rd party API that has it?

Cheers
Sharp



Tony Morris 03-12-2005 06:32 AM

Re: Does Java 1.5 have circular linkedlist implementation?
 
"Sharp" <Sharp@SharpAddress.com> wrote in message
news:_qvYd.193927$K7.152817@news-server.bigpond.net.au...
> Hi
> Does Java 1.5 have circular linkedlist implementation?
> if not, where can I find a 3rd party API that has it?
>
> Cheers
> Sharp
>
>


No.
Google could turn one up, but I see no reason to spend the 5 or 10 minutes
writing it yourself instead (perhaps a tad more if you write tests and
javadoc, like you should).
Note that a circular linked list cannot be implemented successfully (without
design flaws) by implementing the java.util.List interface -I've seen many
of my university students try.

--
Tony Morris
http://xdweb.net/~dibblego/




Kevin McMurtrie 03-12-2005 07:58 AM

Re: Does Java 1.5 have circular linkedlist implementation?
 
In article <v2wYd.193981$K7.16320@news-server.bigpond.net.au>,
"Tony Morris" <not@telling.you> wrote:

> "Sharp" <Sharp@SharpAddress.com> wrote in message
> news:_qvYd.193927$K7.152817@news-server.bigpond.net.au...
> > Hi
> > Does Java 1.5 have circular linkedlist implementation?
> > if not, where can I find a 3rd party API that has it?
> >
> > Cheers
> > Sharp
> >
> >

>
> No.
> Google could turn one up, but I see no reason to spend the 5 or 10 minutes
> writing it yourself instead (perhaps a tad more if you write tests and
> javadoc, like you should).
> Note that a circular linked list cannot be implemented successfully (without
> design flaws) by implementing the java.util.List interface -I've seen many
> of my university students try.


I don't see why it can't implement List if given a reference point and
direction. It couldn't cleanly support concurrent modification through
itself and an Iterator but that's a common limitation.

Thomas G. Marshall 03-13-2005 06:12 AM

Re: Does Java 1.5 have circular linkedlist implementation?
 
Kevin McMurtrie coughed up:
> In article <v2wYd.193981$K7.16320@news-server.bigpond.net.au>,
> "Tony Morris" <not@telling.you> wrote:
>
>> "Sharp" <Sharp@SharpAddress.com> wrote in message
>> news:_qvYd.193927$K7.152817@news-server.bigpond.net.au...
>>> Hi
>>> Does Java 1.5 have circular linkedlist implementation?
>>> if not, where can I find a 3rd party API that has it?
>>>
>>> Cheers
>>> Sharp
>>>
>>>

>>
>> No.
>> Google could turn one up, but I see no reason to spend the 5 or 10
>> minutes writing it yourself instead (perhaps a tad more if you write
>> tests and javadoc, like you should).
>> Note that a circular linked list cannot be implemented successfully
>> (without design flaws) by implementing the java.util.List interface
>> -I've seen many of my university students try.

>
> I don't see why it can't implement List if given a reference point and
> direction.


I've seen this discussion a few times. You can specify a reference point,
but that reference point is hard to pin down in a generic sense. What
constitutes the head, or better put, "the way in" to a circular linked list
is often goofy.


> It couldn't cleanly support concurrent modification
> through itself and an Iterator but that's a common limitation.



You could specify a ListIterator, which is what you get from List
implementors anyway. And a ListIterator has the add() and remove() methods
needed for such concurrent things. Once you've chosen that arbitrary head
and tail in the circle, the ListIterator could be designed in a similar way
it is for ArrayList.



--
Whyowhydidn'tsunmakejavarequireanuppercaseletterto startclassnames....



tennenrishin 07-05-2011 08:00 PM

Java implementation of CircularArrayList:
http://www.museful.net/2011/sw-devel...ylist-for-java


All times are GMT. The time now is 04:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.