On Thursday 30 October 2008 00:31, Daniel Cheng wrote:
> On Thu, Oct 30, 2008 at 3:37 AM, <xor at freenetproject.org> wrote:
> > Author: xor
> > Date: 2008-10-29 19:37:09 +0000 (Wed, 29 Oct 2008)
> > New Revision: 23181
> >
> > Modified:
> > trunk/freenet/src/freenet/support/DoublyLinkedList.java
> > trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java
> > trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
> >
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
> > Log:
> > Add contains() functions.
> >
> > Modified: trunk/freenet/src/freenet/support/DoublyLinkedList.java
> > ===================================================================
> > --- trunk/freenet/src/freenet/support/DoublyLinkedList.java 2008-10-29
19:26:30 UTC (rev 23180)
> > +++ trunk/freenet/src/freenet/support/DoublyLinkedList.java 2008-10-29
19:37:09 UTC (rev 23181)
> > @@ -47,7 +47,13 @@
> > /** Get a {@link Enumeration} of {@link DoublyLinkedList.Item}. */
> > Enumeration elements(); // for consistency w/ typical Java API
> >
> > +
> > /**
> > + * Returns true if the passed item is contained in the list.
> > + */
> > + public boolean contains(DoublyLinkedList.Item<T> item);
> > +
> > + /**
> > * Returns the first item.
> > * @return the item at the head of the list, or <code>null</code> if
empty
> > */
> >
> > Modified: trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java
> > ===================================================================
> > --- trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java 2008-10-29
19:26:30 UTC (rev 23180)
> > +++ trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java 2008-10-29
19:37:09 UTC (rev 23181)
> > @@ -116,6 +116,14 @@
> > return forwardElements();
> > }
> >
> > + public boolean contains(DoublyLinkedList.Item<T> item) {
> > + for(T i : this) {
> > + if(i == item)
>
> use .equals() ?
>
> > + return true;
> > + }
> > + return false;
> > + }
> > +
Why not just check the parent pointer on the Item? Maybe with an iteration as
above as a debugging double-check?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20081030/6452cb9a/attachment.pgp>