Class ListLinked<T>


  • public class ListLinked<T>
    extends java.lang.Object
    A better linked list implementation than provided by java.util. TODO: Looks like the main benefit is a non-failing iterator. In JDK 1.5 this may not be needed. 1.5 has better Iterators in the collections classes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<T> add​(T o)
      Add object to end of the list, any existing iterators remain valid
      void clear()
      Get rid of all entries on the linked list.
      java.util.Iterator<T> insertAfter​(java.util.Iterator<T> itr, T o)
      Insert new object AFTER object pointed to by iterator, other Iterators remain valid
      java.util.Iterator<T> insertBefore​(java.util.Iterator<T> itr, T o)
      Insert new object BEFORE object pointed to by iterator, other Iterators remain valid
      java.util.Iterator<T> iterator()  
      void remove​(java.util.Iterator<T> itr)
      Remove object from list indicated by Iterator, all iterators that point to objects other than this one remain valid
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • add

        public java.util.Iterator<T> add​(T o)
        Add object to end of the list, any existing iterators remain valid
        Parameters:
        o - -- Object to be added
        Returns:
        Iterator to new object
      • insertAfter

        public java.util.Iterator<T> insertAfter​(java.util.Iterator<T> itr,
                                                 T o)
        Insert new object AFTER object pointed to by iterator, other Iterators remain valid
        Parameters:
        itr - Iterator to existing object
        o - New object to add
        Returns:
        Iterator to new object
      • insertBefore

        public java.util.Iterator<T> insertBefore​(java.util.Iterator<T> itr,
                                                  T o)
        Insert new object BEFORE object pointed to by iterator, other Iterators remain valid
        Parameters:
        itr - Iterator to existing object
        o - New object to add
        Returns:
        Iterator to new object
      • remove

        public void remove​(java.util.Iterator<T> itr)
        Remove object from list indicated by Iterator, all iterators that point to objects other than this one remain valid
        Parameters:
        itr - Iterator to object to be removed
      • iterator

        public java.util.Iterator<T> iterator()
        Returns:
        an iterator over this linked list
      • clear

        public void clear()
        Get rid of all entries on the linked list.