All Packages  Class Hierarchy  This Package  Previous  Next  Index

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

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

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

Items can be inserted efficiently at 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 mean 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 efficient access to the end of the list
 o tail_
Sentinel link positioned just past the last node

Constructor Index

 o Slist()
Creates an empty singly-linked list.

Method Index

 o append(Object)
Adds an item 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 clear()
Removes all elements from the list.
 o clone()
Returns a clone of this Slist.
 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 an 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()) item.
 o occurrencesOfReference(Object)
Returns the number of items in the list identical to (==) the given item.
 o prepend(Object)
Adds an 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(Slink)
 o toString()
Converts this Slist to a string.
 o transform(UnaryFunction)
Replaces each member of the collection with the result of applying the unary function to that memeber.

Variables

 o head_
 protected Slink head_
Sentinel link pointing to first node

 o tail_
 protected Slink tail_
Sentinel link positioned just past the last node

 o last_
 protected Slink last_
reference to last node for efficient access to the end of the list

Constructors

 o Slist
 public Slist()
Creates an empty singly-linked list.

Methods

 o append
 public synchronized Object append(Object item)
Adds an item 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: SlistIndexOutOfBoundsException
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. i must be between 0 and one less than the number of entries.

Returns:
The previous element at position i
Throws: SlistIndexOutOfBoundsException
If i is not between 0 and one less than the number of elements in the list
 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 Slist. 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.

Overrides:
elements in class CollectionBase
 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 an 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 the new object will be added to the end of the list.

Returns:
The new element
Throws: SlistIndexOutOfBoundsException
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()) 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 an 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: SlistIndexOutOfBoundsException
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 this Slist 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 collection 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 Slink removeRight(Slink link)

All Packages  Class Hierarchy  This Package  Previous  Next  Index