Author: j16sdiz
Date: 2009-02-22 11:20:23 +0000 (Sun, 22 Feb 2009)
New Revision: 25758

Modified:
   trunk/freenet/src/freenet/support/DoublyLinkedList.java
Log:
Generic for DoublyLinkedList interface (bug 2512)

Fix the interface to fit real use. remove clone() requirment.

Modified: trunk/freenet/src/freenet/support/DoublyLinkedList.java
===================================================================
--- trunk/freenet/src/freenet/support/DoublyLinkedList.java     2009-02-21 
13:51:30 UTC (rev 25757)
+++ trunk/freenet/src/freenet/support/DoublyLinkedList.java     2009-02-22 
11:20:23 UTC (rev 25758)
@@ -6,36 +6,36 @@
  * Framework for managing a doubly linked list.
  * @author tavin
  */
-public interface DoublyLinkedList<T> extends Iterable<T> {
-    public abstract DoublyLinkedList<T> clone();
+public interface DoublyLinkedList<T extends DoublyLinkedList.Item<?>> extends 
Iterable<T> {
+       // public abstract DoublyLinkedList<T> clone();
 
     /**
      * List element
      */
-    public interface Item<T> {
+       public interface Item<T extends DoublyLinkedList.Item<?>> {
                /**
                 * Get next {...@link Item}. May or may not return
                 * <code>null</code> if this is the last <code>Item</code>.
                 * 
                 * @see DoublyLinkedList#hasNext()
                 */
-        DoublyLinkedList.Item<T> getNext();
+               T getNext();
         /** Set next {...@link Item} */
-        DoublyLinkedList.Item<T> setNext(DoublyLinkedList.Item<T> i);
+               T setNext(Item<?> i);
         /**
         * Get previous {...@link Item}. May or may not return <code>null</code>
         * if this is the first <code>Item</code>.
         * 
         * @see DoublyLinkedList#hasNext()
         */
-        Item<T> getPrev();
+               T getPrev();
         /** Get previous {...@link Item} */
-        Item<T> setPrev(DoublyLinkedList.Item<T> i);
+               T setPrev(Item<?> i);
         
         /** Return the contained list. <strong>For sanity checking 
only.</strong> */
-        DoublyLinkedList<T> getParent();
+               DoublyLinkedList<? super T> getParent();
         /** Set the contained list. <strong>For sanity checking 
only.</strong>*/
-        DoublyLinkedList<T> setParent(DoublyLinkedList<T> l);
+               DoublyLinkedList<? super T> setParent(DoublyLinkedList<? super 
T> l);
     }
     
     /** Clear this list */
@@ -45,33 +45,32 @@
     /** Check if this list is empty. @return <code>true</code> if this list is 
empty, <code>false</code> otherwise. */
     boolean isEmpty();
     /** Get a {...@link Enumeration} of {...@link DoublyLinkedList.Item}. */
-    Enumeration elements();   // for consistency w/ typical Java API
+       Enumeration<T> 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);
+       public boolean contains(T item);
     
     /**
      * Returns the first item.
      * @return  the item at the head of the list, or <code>null</code> if empty
      */
-    Item head();
+       T head();
     /**
      * Returns the last item.
      * @return  the item at the tail of the list, or <code>null</code> if empty
      */
-    Item tail();
+       T tail();
 
     /**
      * Puts the item before the first item.
      */
-    void unshift(DoublyLinkedList.Item<T> i);
+       void unshift(T i);
     /**
      * Removes and returns the first item.
      */
-    Item shift();
+       T shift();
     /**
      * Remove <tt>n</tt> elements from head and return them as a 
<code>DoublyLinkedList</code>.
      */
@@ -80,37 +79,37 @@
     /**
      * Puts the item after the last item.
      */
-    void push(DoublyLinkedList.Item<T> i);
+       void push(T i);
     /**
      * Removes and returns the last item.
      */
-    Item pop();
+       T pop();
     /**
      * Remove <tt>n</tt> elements from tail and return them as a 
<code>DoublyLinkedList</code>.
      */
-    DoublyLinkedList pop(int n);
+       DoublyLinkedList<T> pop(int n);
 
     /** @return <code>true</code> if <code>i</code> has next item. (ie. not 
the last item); <code>false</code> otherwise */ 
-    boolean hasNext(DoublyLinkedList.Item<T> i);
+       boolean hasNext(T i);
     /** @return <code>true</code> if <code>i</code> has previous item. (ie. 
not the first item); <code>false</code> otherwise */
-    boolean hasPrev(DoublyLinkedList.Item<T> i);
+       boolean hasPrev(T i);
 
     /** @return next item of <code>i</code>. If this is the last element, 
return <code>null</code> */
-    Item next(DoublyLinkedList.Item<T> i);
+       T next(T i);
     /** @return previous item of <code>i</code>. If this is the first element, 
return <code>null</code> */
-    Item prev(DoublyLinkedList.Item<T> i);
+       T prev(T i);
     /** Remove and return a element 
      * @return  this item, or <code>null</code> if the item was not in the list
      */
-    Item remove(DoublyLinkedList.Item<T> i);
+       T remove(T i);
     /**
      * Inserts item <code>j</code> before item <code>i</code>.
      */
-    void insertPrev(DoublyLinkedList.Item<T> i, DoublyLinkedList.Item<T> j);
+       void insertPrev(T i, T j);
     /**
      * Inserts item <code>j</code> after item <code>i</code.
      */
-    void insertNext(DoublyLinkedList.Item<T> i, DoublyLinkedList.Item<T> j); 
+       void insertNext(T i, T j);
 }
 
 

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

Reply via email to