coins.backend.util
Class BiList

java.lang.Object
  extended bycoins.backend.util.BiLink
      extended bycoins.backend.util.BiList
All Implemented Interfaces:
java.lang.Cloneable

public class BiList
extends BiLink
implements java.lang.Cloneable

Bi-directional list (head part)


Nested Class Summary
(package private)  class BiList.BiListIterator
          Iterator for scanning a BiList.
 
Field Summary
 
Fields inherited from class coins.backend.util.BiLink
elem, next, prev
 
Constructor Summary
BiList()
          Create empty list.
 
Method Summary
 BiLink add(java.lang.Object obj)
          Append an element to the end of the list.
 BiLink addAll(BiList list)
          Append all element in the list to the end.
 BiLink addAllFirst(BiList list)
          Add an element before first element of the list.
 BiLink addFirst(java.lang.Object obj)
          Add an element before first element of the list.
 BiList addNew(java.lang.Object obj)
          Add an object to the list only if not there.
 BiLink append(BiLink link)
          Append a link to the end of the list.
 boolean atEnd()
          Return true if this link is either end.
 void clear()
          Clear the list.
 java.lang.Object clone()
          Return copy of the list.
 BiList concatenate(BiList aList)
          Concatenate two lists.
 boolean contains(java.lang.Object obj)
          Test if the list contains an object obj.
 BiList copy()
          Make a copy of the list and return it.
 java.lang.Object elem()
          Return contents of this link.
 boolean equals(java.lang.Object x)
          Compare two lists
 BiLink first()
          Return first link.
 boolean isEmpty()
          Return true if this list is empty.
 java.util.Iterator iterator()
          Return iterator for the list.
 BiLink last()
          Return last link.
 int length()
          Return length of the list
 BiLink locate(java.lang.Object obj)
          Find a link which has an object obj.
 BiLink locateEqual(java.lang.Object obj)
          Find a link which has an object which equals to obj.
static void main(java.lang.String[] args)
           
 BiLink next()
          Return next link.
 BiLink prepend(BiLink link)
          Prepend a link before first element of the list.
 BiLink prev()
          Return previous link.
 BiLink remove(java.lang.Object obj)
          Remove an link which has an object obj.
 BiLink removeEqual(java.lang.Object obj)
          Remove an link which has an object which equals to obj.
 void sanityTest()
          Check list consistency.
 void sort()
          Sort list.
 void sort(java.util.Comparator cmp)
          Sort list according to Comparator.
 BiList split(BiLink middle)
          Split the list into two parts.
 java.lang.Object takeFirst()
          Return first element and remove it
 java.lang.Object takeLast()
          Return last element and remove it
 java.lang.Object[] toArray()
          Convert to array.
 java.lang.String toString()
          Visualize
 BiLink unlink()
          Remove this link from the list.
 int whereIs(java.lang.Object obj)
          Return the position of first occurence of an object obj.
 
Methods inherited from class coins.backend.util.BiLink
addAfter, addAllAfter, addAllBefore, addBefore, insertAfter, insertAllAfter, insertAllBefore, insertBefore, setElem
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BiList

public BiList()
Create empty list.

Method Detail

elem

public java.lang.Object elem()
Description copied from class: BiLink
Return contents of this link.

Overrides:
elem in class BiLink

unlink

public BiLink unlink()
Description copied from class: BiLink
Remove this link from the list.

Overrides:
unlink in class BiLink
Returns:
the link just removed

next

public BiLink next()
Description copied from class: BiLink
Return next link.

Overrides:
next in class BiLink

prev

public BiLink prev()
Description copied from class: BiLink
Return previous link.

Overrides:
prev in class BiLink

first

public BiLink first()
Return first link.


last

public BiLink last()
Return last link.


atEnd

public boolean atEnd()
Return true if this link is either end.

Overrides:
atEnd in class BiLink

isEmpty

public boolean isEmpty()
Return true if this list is empty.


add

public BiLink add(java.lang.Object obj)
Append an element to the end of the list.


addAll

public BiLink addAll(BiList list)
Append all element in the list to the end.


append

public BiLink append(BiLink link)
Append a link to the end of the list.


addFirst

public BiLink addFirst(java.lang.Object obj)
Add an element before first element of the list.


addAllFirst

public BiLink addAllFirst(BiList list)
Add an element before first element of the list.


prepend

public BiLink prepend(BiLink link)
Prepend a link before first element of the list.


takeLast

public java.lang.Object takeLast()
Return last element and remove it


takeFirst

public java.lang.Object takeFirst()
Return first element and remove it


contains

public boolean contains(java.lang.Object obj)
Test if the list contains an object obj.


locate

public BiLink locate(java.lang.Object obj)
Find a link which has an object obj.


locateEqual

public BiLink locateEqual(java.lang.Object obj)
Find a link which has an object which equals to obj.


whereIs

public int whereIs(java.lang.Object obj)
Return the position of first occurence of an object obj.


remove

public BiLink remove(java.lang.Object obj)
Remove an link which has an object obj.


removeEqual

public BiLink removeEqual(java.lang.Object obj)
Remove an link which has an object which equals to obj.


addNew

public BiList addNew(java.lang.Object obj)
Add an object to the list only if not there.


clear

public void clear()
Clear the list. Make list empty.


concatenate

public BiList concatenate(BiList aList)
Concatenate two lists. Added list will be destroyed.

Parameters:
aList - the list appended
Returns:
this object itself

split

public BiList split(BiLink middle)
Split the list into two parts.

Parameters:
middle - the first element of second half of the list
Returns:
second half of the list (first half is this object)

copy

public BiList copy()
Make a copy of the list and return it. Do not copy the contents; they are shared.


length

public int length()
Return length of the list


sort

public void sort()
Sort list.


sort

public void sort(java.util.Comparator cmp)
Sort list according to Comparator.


equals

public boolean equals(java.lang.Object x)
Compare two lists


toArray

public java.lang.Object[] toArray()
Convert to array.


toString

public java.lang.String toString()
Visualize


clone

public java.lang.Object clone()
Return copy of the list.


iterator

public java.util.Iterator iterator()
Return iterator for the list.


sanityTest

public void sanityTest()
Check list consistency.


main

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