Package net.sf.saxon.ma.trie
Class ImmutableList<T>
java.lang.Object
net.sf.saxon.ma.trie.ImmutableList<T>
- Type Parameters:
 T- the type of the elements in the list
- All Implemented Interfaces:
 Iterable<T>
An immutable list implementation that only supports sequential traversal using an iterator,
 prepending an item to the start, and extraction of the head()/tail() of the list.
 It is optimized for sequential access rather than
 direct access.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ImmutableList<T> empty()Return an empty listbooleanTest whether two lists are equalabstract Thead()Get the first item in the listabstract booleanisEmpty()Ask whether the list is emptyiterator()Get an iterator over the elements of the listReturn a list with a new item added at the startreverse()Return a list with the contents of this list in reverse orderfinal intsize()Get the size of the list (the number of items).abstract ImmutableList<T> tail()Get all items in the list other than the firsttoString()Return a string representation of the list contentsMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator 
- 
Constructor Details
- 
ImmutableList
public ImmutableList() 
 - 
 - 
Method Details
- 
empty
Return an empty list- Type Parameters:
 T- the nominal item type of the list elements- Returns:
 - an empty list
 
 - 
head
Get the first item in the list- Returns:
 - the first item in the list
 
 - 
tail
Get all items in the list other than the first- Returns:
 - a list containing all items except the first
 
 - 
isEmpty
public abstract boolean isEmpty()Ask whether the list is empty- Returns:
 - true if and only if the list contains no items
 
 - 
size
public final int size()Get the size of the list (the number of items). Note that this is an O(n) operation.- Returns:
 - the size of the list.
 
 - 
prepend
Return a list with a new item added at the start- Parameters:
 element- the item to be added at the start- Returns:
 - a new list
 
 - 
equals
Test whether two lists are equal - 
iterator
Get an iterator over the elements of the list - 
toString
Return a string representation of the list contents - 
reverse
Return a list with the contents of this list in reverse order- Returns:
 - the reversed list
 
 
 -