|
|||||||||
| Home >> All >> org >> jdaemon >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jdaemon.util
Class QuickList

java.lang.Objectorg.jdaemon.util.QuickList
- public class QuickList
- extends java.lang.Object
A quick-and-dirty LISP-style list class. QuickList differs from the List Collection in as much as once created, a QuickList does not change. New elements are added to a QuickList by creating a new QuickList which includes both the new element and the old QuickList. This makes QuickList suitable for generating low-overhead temporary data structures (amongst other things).
| Field Summary | |
static QuickList |
EMPTY
Empty Quicklist. |
private java.lang.Object |
head
The first element in this QuickList |
private QuickList |
tail
All elements in this QuickList apart from the first |
| Constructor Summary | |
protected |
QuickList(QuickList tail,
java.lang.Object head)
Creates a new instance of QuickList. |
| Method Summary | |
QuickList |
add(java.util.Iterator items)
Adds serveral items to a list. |
QuickList |
add(java.lang.Object item)
Adds an item to a list. |
private QuickList |
addReverse(QuickList other)
|
boolean |
compareList(QuickList other)
Compare two lists for equality |
boolean |
equals(java.lang.Object other)
Compare two lists for equality implemented using the compareList method but will additionally return false if the object given is not a QuickList. |
java.lang.Object |
find(java.util.Comparator comparator,
java.lang.Object to_compare)
Find an object within the list that matches the one given. |
java.lang.Object |
head()
Get the first item in this list. |
QuickList |
orderedAdd(java.util.Comparator comparator,
java.lang.Object object)
Add an element to the Quicklist, maintaining a pre-existing ordering of elements. |
QuickList |
reverse()
Reverse all elements in this list. |
int |
size()
Calculate the size of a QuickList |
QuickList |
sort(java.util.Comparator comparator)
Create a new QuickList from this one, sorted by the supplied comparator |
QuickList |
tail()
Get the rump of this list (everything except the first item). |
java.util.List |
toList()
Converts a QuickList to a Collection-style List object. |
java.lang.String |
toString()
Write out a comma-separated list of all elements to a String. |
java.lang.String |
toString(java.lang.String separator)
Write out all elements of this quicklist to a String with the given separator. |
protected void |
writeWithSeparator(java.lang.StringBuffer buffer,
java.lang.String separator)
Write out all elements of this quicklist to a StringBuffer with the given separator. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
tail
private QuickList tail
- All elements in this QuickList apart from the first
head
private java.lang.Object head
- The first element in this QuickList
EMPTY
public static final QuickList EMPTY
- Empty Quicklist. Add to the empty QuickList in order to generate a new list
| Constructor Detail |
QuickList
protected QuickList(QuickList tail, java.lang.Object head)
- Creates a new instance of QuickList.
| Method Detail |
add
public QuickList add(java.lang.Object item)
- Adds an item to a list.
Note that this method does not change this list, but instead returns a
new list with the new item added to it.
add
public QuickList add(java.util.Iterator items)
- Adds serveral items to a list.
Note that this method does not change this list, but instead returns a
new list with the new item added to it.
head
public java.lang.Object head()
- Get the first item in this list.
tail
public QuickList tail()
- Get the rump of this list (everything except the first item).
toList
public java.util.List toList()
- Converts a QuickList to a Collection-style List object.
writeWithSeparator
protected void writeWithSeparator(java.lang.StringBuffer buffer, java.lang.String separator)
- Write out all elements of this quicklist to a StringBuffer with the given separator.
Note: This method is protected because it should NOT be applied to EMPTY.
toString
public java.lang.String toString(java.lang.String separator)
- Write out all elements of this quicklist to a String with the given separator.
toString
public java.lang.String toString()
- Write out a comma-separated list of all elements to a String.
find
public java.lang.Object find(java.util.Comparator comparator, java.lang.Object to_compare)
- Find an object within the list that matches the one given.
Finds the first object in this list for which:
comparator.compare(list_object, to_compare) == 0
sort
public QuickList sort(java.util.Comparator comparator)
- Create a new QuickList from this one, sorted by the supplied comparator
orderedAdd
public QuickList orderedAdd(java.util.Comparator comparator, java.lang.Object object)
- Add an element to the Quicklist, maintaining a pre-existing ordering of elements.
For this method to work, the list into which the object is being added must already
be sorted.
reverse
public QuickList reverse()
- Reverse all elements in this list.
addReverse
private QuickList addReverse(QuickList other)
size
public int size()
- Calculate the size of a QuickList
compareList
public boolean compareList(QuickList other)
- Compare two lists for equality
equals
public boolean equals(java.lang.Object other)
- Compare two lists for equality
implemented using the compareList method but will additionally return false if the object given is not a QuickList.
|
|||||||||
| Home >> All >> org >> jdaemon >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.jdaemon.util.QuickList