org.jgroups.util

Class List

public class List extends Object implements Externalizable, Cloneable

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.

Author: Bela Ban

Field Summary
protected List.Elementhead
protected Objectmutex
protected intsize
protected List.Elementtail
Constructor Summary
List()
Method Summary
voidadd(Object obj)
Adds an object at the tail of the list.
voidaddAtHead(Object obj)
Adds an object at the head of the list.
protected Objectclone()
booleancontains(Object obj)
Listcopy()
Stringdump()
Enumerationelements()
VectorgetContents()
static voidmain(String[] args)
Objectpeek()
Returns element at the tail (if present), but does not remove it from list.
ObjectpeekAtHead()
Returns element at the head (if present), but does not remove it from list.
voidreadExternal(ObjectInput in)
Objectremove()
Removes an object from the tail of the list.
voidremoveAll()
ObjectremoveElement(Object obj)
Removes element obj from the list, checking for equality using the equals operator.
ObjectremoveFromHead()
Removes an object from the head of the list.
intsize()
StringtoString()
voidwriteExternal(ObjectOutput out)

Field Detail

head

protected List.Element head

mutex

protected final transient Object mutex

size

protected int size

tail

protected List.Element tail

Constructor Detail

List

public List()

Method Detail

add

public void add(Object obj)
Adds an object at the tail of the list.

addAtHead

public void addAtHead(Object obj)
Adds an object at the head of the list.

clone

protected Object clone()

contains

public boolean contains(Object obj)

copy

public List copy()

dump

public String dump()

elements

public Enumeration elements()

getContents

public Vector getContents()

main

public static void main(String[] args)

peek

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

peekAtHead

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

readExternal

public void readExternal(ObjectInput in)

remove

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

removeAll

public void removeAll()

removeElement

public Object removeElement(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.

removeFromHead

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

size

public int size()

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.