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)
+                       return true;
+       }
+       return false;
+    }
+    
     /**
      * {@inheritDoc}
      */

Modified: trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
===================================================================
--- trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java    
2008-10-29 19:26:30 UTC (rev 23180)
+++ trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java    
2008-10-29 19:37:09 UTC (rev 23181)
@@ -218,6 +218,13 @@
     }

     /**
+     * @return Does the list contain that item?
+     */
+    public synchronized boolean contains(UpdatableSortedLinkedListItem item) {
+       return list.contains(item);
+    }
+    
+    /**
      * @return Is the list empty?
      */
     public synchronized boolean isEmpty() {

Modified: 
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
===================================================================
--- 
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
    2008-10-29 19:26:30 UTC (rev 23180)
+++ 
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
    2008-10-29 19:37:09 UTC (rev 23181)
@@ -50,6 +50,10 @@
     public synchronized boolean containsKey(Object key) {
         return map.containsKey(key);
     }
+    
+    public synchronized boolean 
contains(IndexableUpdatableSortedLinkedListItem item) {
+       return containsKey(item.indexValue());
+    }

     /**
      * Remove an element from the list by its key.


Reply via email to