On Thursday 30 October 2008 00:31, Daniel Cheng wrote:
> On Thu, Oct 30, 2008 at 3:37 AM,  <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED] Enumeration} of [EMAIL PROTECTED] 
> > 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?

Attachment: pgpDwql0auo8X.pgp
Description: PGP signature

_______________________________________________
Devl mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to