JavaGroups
Class List

java.lang.Object
  |
  +--JavaGroups.List
Direct Known Subclasses:
SortedList, Stack

public class List
extends java.lang.Object
implements java.io.Externalizable

Doubly-linked list. Elements can be added at head or tail and removed from head/tail. This class is tuned for element access at either head or tail, random access to elements is not very fast; in this case use Vector. Concurrent access is supported: a thread is blocked while another thread adds/removes an object. When no objects are available, removal returns null.

See Also:
Serialized Form

Constructor Summary
List()
           
 
Method Summary
 void Add(java.lang.Object obj)
          Adds an object at the tail of the list.
 void AddAtHead(java.lang.Object obj)
          Adds an object at the head of the list.
 boolean Contains(java.lang.Object obj)
           
 List Copy()
           
 java.lang.String Dump()
           
 java.util.Enumeration Elements()
           
 java.util.Vector GetContents()
           
static void main(java.lang.String[] args)
           
 java.lang.Object Peek()
          Returns element at the tail (if present), but does not remove it from list.
 java.lang.Object PeekAtHead()
          Returns element at the head (if present), but does not remove it from list.
 void readExternal(java.io.ObjectInput in)
           
 java.lang.Object Remove()
          Removes an object from the tail of the list.
 void RemoveAll()
           
 java.lang.Object RemoveElement(java.lang.Object obj)
          Removes element obj from the list, checking for equality using the equals operator.
 java.lang.Object RemoveFromHead()
          Removes an object from the head of the list.
 int Size()
           
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

List

public List()
Method Detail

Add

public void Add(java.lang.Object obj)
Adds an object at the tail of the list.

AddAtHead

public void AddAtHead(java.lang.Object obj)
Adds an object at the head of the list.

Remove

public java.lang.Object Remove()
Removes an object from the tail of the list. Returns null if no elements available

RemoveFromHead

public java.lang.Object RemoveFromHead()
Removes an object from the head of the list. Returns null if no elements available

Peek

public java.lang.Object Peek()
Returns element at the tail (if present), but does not remove it from list.

PeekAtHead

public java.lang.Object PeekAtHead()
Returns element at the head (if present), but does not remove it from list.

RemoveElement

public java.lang.Object RemoveElement(java.lang.Object obj)
Removes element obj from the list, checking for equality using the equals operator. Only the first duplicate object is removed. Returns the removed object.

RemoveAll

public void RemoveAll()

Size

public int Size()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Dump

public java.lang.String Dump()

GetContents

public java.util.Vector GetContents()

Elements

public java.util.Enumeration Elements()

Contains

public boolean Contains(java.lang.Object obj)

Copy

public List Copy()

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable

main

public static void main(java.lang.String[] args)