UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.collection
Class OrderedList

java.lang.Object
  |
  +--edu.berkeley.guir.lib.collection.OrderedList
All Implemented Interfaces:
Collection, List, Serializable

public class OrderedList
extends Object
implements List, Serializable

A linked list with lots of extra functionality, including:

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, May 09 1999, JH
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
JDK 1.2.1
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
(jasonh@cs.berkeley.edu)
See Also:
Serialized Form

Constructor Summary
OrderedList()
          Create a new, empty, ordered list.
 
Method Summary
 void add(int index, Object obj)
           
 boolean add(Object obj)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void addToBack(Object obj)
          Same as add(), just here for symmetry.
 void addToFront(Object obj)
          Add an item to the front.
 void clear()
           
 Object clone()
          Make a shallow copy.
 boolean contains(Object obj)
           
 boolean containsAll(Collection c)
           
 Enumeration elements()
           
 boolean equals(Object obj)
           
 Object get(int index)
           
 Iterator getForwardIterator()
          Get an iterator that goes through the list in forward order.
 Iterator getReverseIterator()
          Get an iterator that goes through the list in reverse order.
 int hashCode()
           
 int indexOf(Object obj)
           
 boolean isEmpty()
           
 Iterator iterator()
           
 int lastIndexOf(Object obj)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 void moveTo(int xx, int yy)
          Move an item in the list from one position to another.
 void moveToBack(int xx)
          Move the item at the specified position to the back of the list.
 void moveToFront(int xx)
          Move the item at the specified position to the front of the Vector.
 Object remove(int index)
           
 boolean remove(Object obj)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object obj)
           
 int size()
           
 List subList(int fromIndex, int toIndex)
           
 void swap(int xx, int yy)
          Swap two elements in the list given positions.
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedList

public OrderedList()
Create a new, empty, ordered list.
Method Detail

getForwardIterator

public Iterator getForwardIterator()
Get an iterator that goes through the list in forward order.
Returns:
an Iterator going through the list in forward order.

getReverseIterator

public Iterator getReverseIterator()
Get an iterator that goes through the list in reverse order. The current implementation is not as efficient as it could be, but unless it ever becomes a bottleneck its just not worth optimizing.
Returns:
an Iterator going through the list in reverse order.

elements

public Enumeration elements()

addToFront

public void addToFront(Object obj)
Add an item to the front.
Parameters:
obj - is the Object to add.

addToBack

public void addToBack(Object obj)
Same as add(), just here for symmetry.
Parameters:
obj - is the Object to add.

swap

public void swap(int xx,
                 int yy)
Swap two elements in the list given positions. Handles boundary conditions by not doing anything if out of bounds.
Parameters:
xx - is the index of one of the items to swap. It is zero-based.
yy - is the index of one of the items to swap. It is zero-based.

moveTo

public void moveTo(int xx,
                   int yy)
Move an item in the list from one position to another. Items are shifted over to the left as needed. Handles boundary conditions by not doing anything if out of bounds.
Parameters:
xx - is the index of the item to move from. It is zero-based.
yy - is the index of the position to move to. It is zero-based.

moveToFront

public void moveToFront(int xx)
Move the item at the specified position to the front of the Vector.
Parameters:
xx - is the index of the item to move to the front. It is zero-based.

moveToBack

public void moveToBack(int xx)
Move the item at the specified position to the back of the list.
Parameters:
xx - is the index of the item to move to the back. It is zero-based.

add

public void add(int index,
                Object obj)
Specified by:
add in interface List
See Also:
LinkedList.add(int, Object)

add

public boolean add(Object obj)
Specified by:
add in interface List
See Also:
LinkedList.add(Object)

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface List
See Also:
LinkedList.addAll(Collection)

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List
See Also:
LinkedList.addAll(int, Collection)

clear

public void clear()
Specified by:
clear in interface List
See Also:
LinkedList.clear()

contains

public boolean contains(Object obj)
Specified by:
contains in interface List
See Also:
LinkedList.contains(Object)

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface List
See Also:
AbstractCollection.containsAll(Collection)

equals

public boolean equals(Object obj)
Specified by:
equals in interface List
Overrides:
equals in class Object
See Also:
AbstractList.equals(Object)

get

public Object get(int index)
Specified by:
get in interface List
See Also:
LinkedList.get(int)

hashCode

public int hashCode()
Specified by:
hashCode in interface List
Overrides:
hashCode in class Object
See Also:
AbstractList.hashCode()

indexOf

public int indexOf(Object obj)
Specified by:
indexOf in interface List
See Also:
LinkedList.indexOf(Object)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface List
See Also:
AbstractCollection.isEmpty()

iterator

public Iterator iterator()
Specified by:
iterator in interface List
See Also:
AbstractSequentialList.iterator()

lastIndexOf

public int lastIndexOf(Object obj)
Specified by:
lastIndexOf in interface List
See Also:
LinkedList.lastIndexOf(Object)

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List
See Also:
AbstractList.listIterator()

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
See Also:
LinkedList.listIterator(int)

remove

public Object remove(int index)
Specified by:
remove in interface List
See Also:
LinkedList.remove(int)

remove

public boolean remove(Object obj)
Specified by:
remove in interface List
See Also:
LinkedList.remove(Object)

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface List
See Also:
AbstractCollection.removeAll(Collection)

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface List
See Also:
AbstractCollection.retainAll(Collection)

set

public Object set(int index,
                  Object obj)
Specified by:
set in interface List
See Also:
LinkedList.set(int, Object)

size

public int size()
Specified by:
size in interface List
See Also:
LinkedList.size()

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List
See Also:
AbstractList.subList(int, int)

toArray

public Object[] toArray()
Specified by:
toArray in interface List
See Also:
LinkedList.toArray()

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface List
See Also:
LinkedList.toArray(Object[])

clone

public Object clone()
Make a shallow copy.
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

Copyright Information