All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.objectspace.jgl.DList

java.lang.Object
   |
   +----COM.objectspace.jgl.DList

public class DList
extends Object
implements Sequence
A DList is a doubly-linked list, a sequential container that is optimized for insertion and erasure at arbitrary points in its structure.

A DList is useful when the order of items and fast arbitrary insertion/erasure are important. DLists are not as efficient as Deques when insertion and erasure only take place at the extremities.

A DList is implemented as a doubly-linked list in which every node in the list has a pointer to the previous node and a pointer to the next node.

Insertion does not affect iterators or references. Insertion of a single element into a DList takes constant time. Insertion of multiple elements into a DList is linear in the number of elements inserted.

Removal only invalidates the iterators and references to the removed elements. Removing a single element is a constant time operation. Removing a range in a DList is linear time in the size of the range.

See Also:
Sequence, DListExamples

Constructor Index

 o DList()
Construct myself to be an empty DList.
 o DList(DList)
Construct myself to be a shallow copy of an existing DList.
 o DList(int)
Construct myself to contain a specified number of null elements.
 o DList(int, Object)
Construct myself to contain a specified number of elements set to a particular object.

Method Index

 o add(Object)
Add an object after my last element and return null.
 o at(int)
Return the element at the specified index.
 o back()
Return my last item.
 o begin()
Return an iterator positioned at my first item.
 o clear()
Remove all of my elements.
 o clone()
Return a shallow copy of myself.
 o contains(Object)
Return true if I contain a particular object.
 o copy(DList)
Become a shallow copy of an existing DList.
 o count(DListIterator, DListIterator, Object)
Return the number of objects within a specified range of that match a particular value.
 o count(int, int, Object)
Return the number of objects within a specified range of that match a particular value.
 o count(Object)
Return the number of objects that match a particular value.
 o elements()
Return an Enumeration of my components.
 o end()
Return an iterator positioned immediately after my last item.
 o equals(DList)
Return true if I contain the same items in the same order as another DList.
 o equals(Object)
Return true if I'm equal to another object.
 o find(DListIterator, DListIterator, Object)
Return an iterator positioned at the first object within a specified range that matches a particular object, or end() if the object is not found.
 o find(Object)
Return an iterator positioned at the first object that matches a particular value, or end() if the object is not found.
 o finish()
Return an iterator positioned immediately afer my last item.
 o front()
Return my first item.
 o hashCode()
Return my hash code for support of hashing containers
 o indexOf(int, int, Object)
Return an iterator positioned at the first object within a specified range that matches a particular object, or -1 if the object is not found.
 o indexOf(Object)
Return the index of the first object that matches a particular value, or -1 if the object is not found.
 o insert(DListIterator, InputIterator, InputIterator)
Insert a sequence of objects at a particular location.
 o insert(DListIterator, int, Object)
Insert multiple objects at a particular position.
 o insert(DListIterator, Object)
Insert an object at a particular position and return an iterator positioned at the new element.
 o insert(int, int, Object)
Insert multiple objects at a particular index.
 o insert(int, Object)
Insert an object at a particular index.
 o isEmpty()
Return true if I contain no entries.
 o maxSize()
Return the maximum number of entries that I can contain.
 o popBack()
Remove and return my last element.
 o popFront()
Remove and return my first element.
 o pushBack(Object)
Add an object after my last element.
 o pushFront(Object)
Insert an object in front of my first element.
 o put(int, Object)
Set the element at the specified index to a particular object.
 o remove(Enumeration)
Remove the element at a particular position.
 o remove(Enumeration, Enumeration)
Remove the elements in the range [ first..last ).
 o remove(Enumeration, Enumeration, Object)
Remove all elements within a specified range that match a particular object and return the number of objects that were removed.
 o remove(int)
Remove the element at a particular index.
 o remove(int, int)
Remove the elements within a range of indices.
 o remove(int, int, Object)
Remove all elements within a specified range that match a particular object and return the number of objects that were removed.
 o remove(Object)
Remove all elements that match a particular object and return the numbers of objects that were removed.
 o remove(Object, int)
Remove at most a given number of elements that match a particular object and return the number of objects that were removed.
 o replace(DListIterator, DListIterator, Object, Object)
Replace all elements within a specified range that match a particular object with a new value and return the number of objects that were replaced.
 o replace(int, int, Object, Object)
Replace all elements within a specified range that match a particular object with a new value and return the number of objects that were replaced.
 o replace(Object, Object)
Replace all elements that match a particular object with a new value and return the number of objects that were replaced.
 o reverse()
Reverse the order of my elements.
 o size()
Return the number of entries that I contain.
 o splice(DListIterator, DList)
Remove all of the elements in a specified DList and insert them at a particular position.
 o splice(DListIterator, DList, DListIterator)
Remove a specified element from a DList and insert it at a particular position.
 o splice(DListIterator, DList, DListIterator, DListIterator)
Splice a range of elements from a DList into a particular position.
 o splice(int, DList)
Remove all of the elements in a specified DList and insert them at a particular position.
 o splice(int, DList, int)
Remove a specified element from a DList and insert it at a particular position.
 o splice(int, DList, int, int)
Splice a range of elements from a DList and insert them at a particular position.
 o start()
Return an iterator positioned at my first item.
 o swap(DList)
Swap my contents with another DList.
 o toString()
Return a string that describes me.
 o unique()
Replace all repeating sequences of a single element by a single occurrence of that element.

Constructors

 o DList
  public DList()
Construct myself to be an empty DList.

 o DList
  public DList(int size)
Construct myself to contain a specified number of null elements.

Parameters:
size - The number of elements to contain.
Throws: IllegalArgumentException
If the specified size is negative.
 o DList
  public DList(int size,
               Object object)
Construct myself to contain a specified number of elements set to a particular object.

Parameters:
size - The number of elements to contain.
object - The initial value of each element.
Throws: IllegalArgumentException
If the specified size is negative.
 o DList
  public DList(DList list)
Construct myself to be a shallow copy of an existing DList.

Parameters:
DList - The DList to copy.

Methods

 o clone
  public synchronized Object clone()
Return a shallow copy of myself.

Overrides:
clone in class Object
 o equals
  public boolean equals(Object object)
Return true if I'm equal to another object.

Parameters:
object - The object to compare myself against.
Overrides:
equals in class Object
 o equals
  public synchronized boolean equals(DList list)
Return true if I contain the same items in the same order as another DList. Use equals() to compare the individual elements.

Parameters:
list - The DList to compare myself against.
 o hashCode
  public synchronized int hashCode()
Return my hash code for support of hashing containers

Overrides:
hashCode in class Object
 o toString
  public synchronized String toString()
Return a string that describes me.

Overrides:
toString in class Object
 o copy
  public synchronized void copy(DList list)
Become a shallow copy of an existing DList.

Parameters:
list - The DList that I shall become a shallow copy of.
 o isEmpty
  public boolean isEmpty()
Return true if I contain no entries.

 o size
  public int size()
Return the number of entries that I contain.

 o maxSize
  public int maxSize()
Return the maximum number of entries that I can contain.

 o at
  public synchronized Object at(int index)
Return the element at the specified index.

Parameters:
index - The index.
Throws: IndexOutOfBoundsException
If the index is not valid.
 o put
  public synchronized void put(int index,
                               Object object)
Set the element at the specified index to a particular object.

Parameters:
index - The index.
object - The object.
Throws: IndexOutOfBoundsException
If the index is not valid.
 o insert
  public synchronized DListIterator insert(DListIterator pos,
                                           Object object)
Insert an object at a particular position and return an iterator positioned at the new element.

Parameters:
pos - An iterator positioned at the element that the object will be inserted immediately before.
object - The object to insert.
 o insert
  public synchronized void insert(int index,
                                  Object object)
Insert an object at a particular index.

Parameters:
index - The index of the element that the object will be inserted immediately before.
object - The object to insert.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o insert
  public synchronized void insert(DListIterator pos,
                                  int n,
                                  Object object)
Insert multiple objects at a particular position.

Parameters:
pos - An iterator positioned at the element that the objects will be inserted immediately before.
n - The number of objects to insert.
object - The object to insert.
 o insert
  public synchronized void insert(int index,
                                  int n,
                                  Object object)
Insert multiple objects at a particular index.

Parameters:
index - The index of the element that the objects will be inserted immediately before.
object - The object to insert.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o insert
  public synchronized void insert(DListIterator pos,
                                  InputIterator first,
                                  InputIterator last)
Insert a sequence of objects at a particular location.

Parameters:
pos - The location of the element that the objects will be inserted immediately before.
first - An iterator positioned at the first element to insert.
last - An iterator positioned immediately after the last element to insert.
 o back
  public synchronized Object back()
Return my last item.

Throws: InvalidOperationException
If the DList is empty.
 o front
  public synchronized Object front()
Return my first item.

Throws: InvalidOperationException
If the DList is empty.
 o clear
  public synchronized void clear()
Remove all of my elements.

 o remove
  public synchronized int remove(int first,
                                 int last)
Remove the elements within a range of indices.

Parameters:
first - The index of the first element to remove.
last - The index of the last element to remove.
Returns:
The number of elements removed.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o remove
  public synchronized int remove(Enumeration first,
                                 Enumeration last)
Remove the elements in the range [ first..last ).

Parameters:
first - An Enumeration positioned at the first object to remove.
last - An Enumeration positioned immediately after the last object to remove.
Returns:
The number of elements removed.
Throws: IllegalArgumentException
is the Enumeration isn't a DListIterator for this DList object.
 o remove
  public synchronized Object remove(int index)
Remove the element at a particular index.

Parameters:
index - The index of the element to remove.
Returns:
The object removed.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o remove
  public synchronized Object remove(Enumeration pos)
Remove the element at a particular position.

Parameters:
pos - An Enumeration positioned at the element to remove.
Returns:
The object removed.
Throws: IllegalArgumentException
is the Enumeration isn't a DListIterator for this DList object.
 o splice
  public synchronized void splice(int index,
                                  DList list)
Remove all of the elements in a specified DList and insert them at a particular position.

Parameters:
index - The index of the element that the items will be inserted immediately before.
list - The DList to splice the elements from.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o splice
  public synchronized void splice(DListIterator pos,
                                  DList list)
Remove all of the elements in a specified DList and insert them at a particular position.

Parameters:
pos - The position to insert the elements.
list - The DList to splice the elements from.
 o splice
  public synchronized void splice(DListIterator to,
                                  DList list,
                                  DListIterator from)
Remove a specified element from a DList and insert it at a particular position.

Parameters:
to - The position to insert the element.
list - The DList to splice the element from.
from - The position of the element to splice.
 o splice
  public synchronized void splice(int to,
                                  DList list,
                                  int from)
Remove a specified element from a DList and insert it at a particular position.

Parameters:
to - The index of the element that the item will be inserted immediately before.
list - The DList to splice the element from.
from - The index of the element to splice.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o splice
  public synchronized void splice(DListIterator pos,
                                  DList list,
                                  DListIterator first,
                                  DListIterator last)
Splice a range of elements from a DList into a particular position.

Parameters:
pos - The position to insert the elements.
list - The list to splice the elements from.
first - An iterator positioned at the first element to splice.
last - An iterator positioned immediately after the last element to splice.
 o splice
  public synchronized void splice(int index,
                                  DList list,
                                  int first,
                                  int last)
Splice a range of elements from a DList and insert them at a particular position.

Parameters:
index - The index of the item that the elements should be inserted immediately before.
list - The DList to splice the elements from.
first - The index of the first element to splice.
last - The index of the last element to splice.
Throws: IndexOutOfBoundsException
If any index is invalid.
 o unique
  public synchronized void unique()
Replace all repeating sequences of a single element by a single occurrence of that element.

 o popBack
  public synchronized Object popBack()
Remove and return my last element.

Throws: InvalidOperationException
If the DList is empty.
 o pushFront
  public synchronized void pushFront(Object object)
Insert an object in front of my first element.

Parameters:
object - The object to insert.
 o popFront
  public synchronized Object popFront()
Remove and return my first element.

Throws: InvalidOperationException
If the DList is empty.
 o add
  public synchronized Object add(Object object)
Add an object after my last element and return null. This function is a synonym for pushBack().

Parameters:
object - The object to add.
 o pushBack
  public synchronized void pushBack(Object object)
Add an object after my last element.

Parameters:
The - object to add.
 o swap
  public synchronized void swap(DList list)
Swap my contents with another DList.

Parameters:
list - The DList that I will swap my contents with.
 o remove
  public synchronized int remove(Object object)
Remove all elements that match a particular object and return the numbers of objects that were removed.

Parameters:
object - The object to remove.
 o remove
  public synchronized int remove(Object object,
                                 int count)
Remove at most a given number of elements that match a particular object and return the number of objects that were removed.

Parameters:
object - The object to remove.
count - The maximum number of objects to remove.
 o remove
  public synchronized int remove(Enumeration first,
                                 Enumeration last,
                                 Object object)
Remove all elements within a specified range that match a particular object and return the number of objects that were removed.

Parameters:
first - An Enumeration positioned at the first object to remove.
last - An Enumeration positioned immediately after the last object to remove.
object - The object to remove.
Throws: IllegalArgumentException
is the Enumeration isn't a DListIterator for this DList object.
 o remove
  public synchronized int remove(int first,
                                 int last,
                                 Object object)
Remove all elements within a specified range that match a particular object and return the number of objects that were removed.

Parameters:
first - The index of the first object to remove.
last - The index of the last object to remove.
object - The object to remove.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o begin
  public synchronized DListIterator begin()
Return an iterator positioned at my first item.

 o start
  public ForwardIterator start()
Return an iterator positioned at my first item.

 o end
  public synchronized DListIterator end()
Return an iterator positioned immediately after my last item.

 o finish
  public ForwardIterator finish()
Return an iterator positioned immediately afer my last item.

 o elements
  public synchronized Enumeration elements()
Return an Enumeration of my components.

 o replace
  public synchronized int replace(Object oldValue,
                                  Object newValue)
Replace all elements that match a particular object with a new value and return the number of objects that were replaced.

Parameters:
oldValue - The object to be replaced.
newValue - The value to substitute.
 o replace
  public synchronized int replace(DListIterator first,
                                  DListIterator last,
                                  Object oldValue,
                                  Object newValue)
Replace all elements within a specified range that match a particular object with a new value and return the number of objects that were replaced.

Parameters:
first - An iterator positioned at the first object to be considered.
last - An iterator positioned immediately after the last object to be considered.
oldValue - The object to be replaced.
newValue - The value to substitute.
 o replace
  public synchronized int replace(int first,
                                  int last,
                                  Object oldValue,
                                  Object newValue)
Replace all elements within a specified range that match a particular object with a new value and return the number of objects that were replaced.

Parameters:
first - The index of the first object to be considered.
last - The index of the last object to be considered.
oldValue - The object to be replaced.
newValue - The value to substitute.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o count
  public synchronized int count(Object object)
Return the number of objects that match a particular value.

Parameters:
object - The object to count.
 o count
  public synchronized int count(DListIterator first,
                                DListIterator last,
                                Object object)
Return the number of objects within a specified range of that match a particular value.

Parameters:
first - An iterator positioned at the first object to consider.
last - An iterator positioned immediately after the last object to consider.
 o count
  public synchronized int count(int first,
                                int last,
                                Object object)
Return the number of objects within a specified range of that match a particular value.

Parameters:
first - The index of the first object to consider.
last - The index of the last object to consider.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o find
  public synchronized DListIterator find(Object object)
Return an iterator positioned at the first object that matches a particular value, or end() if the object is not found.

Parameters:
object - The object to find.
 o indexOf
  public synchronized int indexOf(Object object)
Return the index of the first object that matches a particular value, or -1 if the object is not found.

Parameters:
object - The object to find.
 o find
  public synchronized DListIterator find(DListIterator first,
                                         DListIterator last,
                                         Object object)
Return an iterator positioned at the first object within a specified range that matches a particular object, or end() if the object is not found.

Parameters:
first - An iterator positioned at the first object to consider.
last - An iterator positioned immediately after the last object to consider.
object - The object to find.
 o indexOf
  public synchronized int indexOf(int first,
                                  int last,
                                  Object object)
Return an iterator positioned at the first object within a specified range that matches a particular object, or -1 if the object is not found.

Parameters:
first - The index of the first object to consider.
last - The index of the last object to consider.
object - The object to find.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o contains
  public synchronized boolean contains(Object object)
Return true if I contain a particular object.

Parameters:
object - The object in question.
 o reverse
  public synchronized void reverse()
Reverse the order of my elements.


All Packages  Class Hierarchy  This Package  Previous  Next  Index