Truncate a LinkedList

2013-02-19 Thread Weijun Wang
Hi All I'm using LinkedList to maintain a history and the elements are ordered by their timestamps. Every now and then I would expunge the list, that is to say, iterating through the list and when an element is old enough all elements after (and including) it will be removed. Currently I'm

Re: Truncate a LinkedList

2013-02-19 Thread Daniel Fuchs
On 2/19/13 11:27 AM, Weijun Wang wrote: Hi All I'm using LinkedList to maintain a history and the elements are ordered by their timestamps. Every now and then I would expunge the list, that is to say, iterating through the list and when an element is old enough all elements after (and

Re: Truncate a LinkedList

2013-02-19 Thread Peter Levart
On 02/19/2013 11:38 AM, Daniel Fuchs wrote: On 2/19/13 11:27 AM, Weijun Wang wrote: Hi All I'm using LinkedList to maintain a history and the elements are ordered by their timestamps. Every now and then I would expunge the list, that is to say, iterating through the list and when an element is

Re: Truncate a LinkedList

2013-02-19 Thread Peter Levart
On 02/19/2013 01:24 PM, Peter Levart wrote: On 02/19/2013 11:38 AM, Daniel Fuchs wrote: On 2/19/13 11:27 AM, Weijun Wang wrote: Hi All I'm using LinkedList to maintain a history and the elements are ordered by their timestamps. Every now and then I would expunge the list, that is to say,

Re: Truncate a LinkedList

2013-02-19 Thread Stephen Colebourne
On 19 February 2013 10:27, Weijun Wang weijun.w...@oracle.com wrote: I'm using LinkedList to maintain a history Don't use LinkedList. Multiple benchmarks down the years have shown it is almost always worse than ArrayList. Stephen and the elements are ordered by their timestamps. Every now

Re: Truncate a LinkedList

2013-02-19 Thread Weijun Wang
In my case, I am planning to do an expunge when there are more old entries than new entries (or plus a constant), so the head and tail are likely of the same size. I'll think about creating my own LinkedList. It will be nice to just break at one link. Thanks Max On 2/19/13 8:36 PM, Peter