All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.roguewave.tools.v2-0.Dlist

java.lang.Object
   |
   +----com.roguewave.tools.v2-0.CollectionBase
           |
           +----com.roguewave.tools.v2-0.Dlist

public class Dlist
extends CollectionBase
implements Cloneable, Serializable, Sequence
Class Dlist implements a doubly-linked list of elements ordered externally by the client of the class. Duplicate entries are allowed.

Items can efficiently be inserted at either the beginning, end, or middle of the list, and likewise for removal. There are several ways to retrieve elements from within the collection. One is by numeric index. Another is by searching for an element which is equal to a given item, as determined by the equals() method inherited or overridden from class Object. Finally, one can search for an element which is identical to a given item, that is, equal in the sense of the == operator.

The primary difference between classes Dlist and Slist is that a Dlist provides an enumerator that allows for movement both forwards and backwards within the collection. The cost is that each node in the Dlist contains one extra pointer over those in an Slist. The storage and maintenance of this extra pointer means that Slists are a tad more efficient in space and time.

See Also:
Slist

Variable Index

 o head_
Sentinel link pointing to first node
 o last_
reference to last node for convenience
 o tail_
Sentinel link positioned past last node

Constructor Index

 o Dlist()
Creates an empty doubly-linked list

Method Index

 o append(Object)
Adds an element to the end of the list
 o at(int)
Returns the ith element of the list where i is between 0 and one less than the number of entries.
 o atPut(int, Object)
Replaces the element at the given position with the given item.
 o bidirectionalElements()
Returns a bidirectional enumeration of the elements in the list.
 o clear()
Removes all elements from the list.
 o clone()
Returns a clone of this Dlist.
 o contains(Object)
Returns true if the list contains an element equal to (equals()) the given item.
 o containsReference(Object)
Returns true if the list contains an element that is identical to (==) the given item.
 o elements()
Returns an enumeration of the elements in the list.
 o find(Object)
Returns the first element in the list equal to (equals()) the given item, or null if no such element is found.
 o first()
Returns the first element of the list.
 o index(Object)
Returns the position (from 0) of the first element in the list equal to (equals()) the given item, or -1 if not found.
 o indexReference(Object)
Returns the position (from 0) of the first element in the list that is identical to (==) the given item, or -1 if not found.
 o init()
Initializes member data as appropriate for an empty list.
 o insert(Object)
Adds the given item to the end of the list.
 o insertAt(int, Object)
Adds the given item to the list in front of the element at the given position.
 o last()
Returns the last element of the list.
 o occurrencesOf(Object)
Returns the number of items in the list equal to (equals()) the given item.
 o occurrencesOfReference(Object)
Returns the number of items in the list identical to (==) the given item.
 o prepend(Object)
Adds the given item to the beginning of the list.
 o remove(Object)
Removes the first element in the list equal to (equals()) the given item.
 o removeAll(Object)
Removes all elements in the list equal to (equals()) the given item.
 o removeAllReference(Object)
Removes all elements in the list identical to (==) the given item.
 o removeAt(int)
Removes the ith element of the list where i is between 0 and one less than the number of entries.
 o removeFirst()
Removes the first element of the list.
 o removeLast()
Removes the last element of the list
 o removeReference(Object)
Removes the first element in the list identical to (==) the given item.
 o removeRight(Dlink)
Removes the Dlink to the right of the given link.
 o toString()
Converts the Dlist to a string.
 o transform(UnaryFunction)
Replaces each member of the list with the result of applying the unary function to that memeber.

Variables

 o head_
 protected Dlink head_
Sentinel link pointing to first node

 o tail_
 protected Dlink tail_
Sentinel link positioned past last node

 o last_
 protected Dlink last_
reference to last node for convenience

Constructors

 o Dlist
 public Dlist()
Creates an empty doubly-linked list

Methods

 o append
 public synchronized Object append(Object item)
Adds an element to the end of the list

Returns:
The new element
 o at
 public synchronized Object at(int i)
Returns the ith element of the list where i is between 0 and one less than the number of entries.

Throws: DlistIndexOutOfBoundsException
If i is not between 0 and one less than the number of elements in the list
 o atPut
 public synchronized Object atPut(int i,
                                  Object item)
Replaces the element at the given position with the given item. tt>i must be between 0 and one less than the number of entries.

Returns:
The previous element at position i
Throws: DlistIndexOutOfBoundsException
If i is not between 0 and one less than the number of elements in the list
 o bidirectionalElements
 public synchronized BidirectionalEnumeration bidirectionalElements()
Returns a bidirectional enumeration of the elements in the list. Use the returned BidirectionalEnumeration object to visit each of the elements in turn, with the ability to move both forwards and backwards through the list.

This method is identical to elements() except that the return value does not have to be downcast from Enumeration to BidirectionalEnumeration.

See Also:
elements
 o clear
 public synchronized void clear()
Removes all elements from the list.

Overrides:
clear in class CollectionBase
 o clone
 public synchronized Object clone()
Returns a clone of this Dlist. Note that the elements themselves are not cloned.

Overrides:
clone in class Object
 o contains
 public boolean contains(Object item)
Returns true if the list contains an element equal to (equals()) the given item.

Overrides:
contains in class CollectionBase
 o containsReference
 public boolean containsReference(Object item)
Returns true if the list contains an element that is identical to (==) the given item.

 o elements
 public synchronized Enumeration elements()
Returns an enumeration of the elements in the list. Use the returned Enumeration object to visit each of the elements in turn.

This method is identical to bidirectionalElements() except that the return value is of type Enumeration, which must be downcast to BidirectionalEnumeration in order to move both forwards and backwards within the list.

Returns:
an enumerator that implements BidirectionalEnumeration
Overrides:
elements in class CollectionBase
See Also:
bidirectionalElements
 o find
 public synchronized Object find(Object item)
Returns the first element in the list equal to (equals()) the given item, or null if no such element is found.

Overrides:
find in class CollectionBase
 o first
 public synchronized Object first()
Returns the first element of the list.

Throws: NoSuchElementException
if the list is empty
 o index
 public synchronized int index(Object item)
Returns the position (from 0) of the first element in the list equal to (equals()) the given item, or -1 if not found.

 o indexReference
 public synchronized int indexReference(Object item)
Returns the position (from 0) of the first element in the list that is identical to (==) the given item, or -1 if not found.

 o insert
 public synchronized Object insert(Object item)
Adds the given item to the end of the list.

Returns:
The new element
Overrides:
insert in class CollectionBase
See Also:
append
 o insertAt
 public synchronized Object insertAt(int i,
                                     Object item)
Adds the given item to the list in front of the element at the given position. If i is equal to the number of elements in the list, then item will be added to the end of the list.

Returns:
The new element
Throws: DlistIndexOutOfBoundsException
If i is not between 0 and the number of elements in the list
 o last
 public synchronized Object last()
Returns the last element of the list.

Throws: NoSuchElementException
if the list is empty
 o occurrencesOf
 public synchronized int occurrencesOf(Object item)
Returns the number of items in the list equal to (equals()) the given item.

Overrides:
occurrencesOf in class CollectionBase
 o occurrencesOfReference
 public synchronized int occurrencesOfReference(Object item)
Returns the number of items in the list identical to (==) the given item.

 o prepend
 public synchronized Object prepend(Object item)
Adds the given item to the beginning of the list.

Returns:
The new element
 o remove
 public synchronized Object remove(Object item)
Removes the first element in the list equal to (equals()) the given item.

Returns:
the element removed, or null if no such element
Overrides:
remove in class CollectionBase
 o removeReference
 public synchronized Object removeReference(Object item)
Removes the first element in the list identical to (==) the given item.

Returns:
the element removed, or null if no such element
 o removeAll
 public synchronized int removeAll(Object item)
Removes all elements in the list equal to (equals()) the given item.

Returns:
The number of elements removed
Overrides:
removeAll in class CollectionBase
 o removeAllReference
 public synchronized int removeAllReference(Object item)
Removes all elements in the list identical to (==) the given item.

Returns:
The number of elements removed
 o removeAt
 public synchronized Object removeAt(int i)
Removes the ith element of the list where i is between 0 and one less than the number of entries.

Returns:
The removed element
Throws: DlistIndexOutOfBoundsException
If i is not between 0 and one less than the number of elements in the list
 o removeFirst
 public synchronized Object removeFirst()
Removes the first element of the list.

Returns:
The removed element
Throws: NoSuchElementException
if the list is empty
 o removeLast
 public synchronized Object removeLast()
Removes the last element of the list

Returns:
The removed element
Throws: NoSuchElementException
if the list is empty
 o toString
 public synchronized String toString()
Converts the Dlist to a string. The string will have the form
   "[elem1, elem2, elem3, ..., elemN]"
 
An empty list returns the string "[]".

Overrides:
toString in class Object
 o transform
 public synchronized void transform(UnaryFunction fun)
Replaces each member of the list with the result of applying the unary function to that memeber.

 o init
 protected void init()
Initializes member data as appropriate for an empty list.

 o removeRight
 protected Dlink removeRight(Dlink link)
Removes the Dlink to the right of the given link. It is an error if link is the last link.


All Packages  Class Hierarchy  This Package  Previous  Next  Index