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:
- java.lang.Iterable<T>
 
 public abstract class ImmutableList<T> extends java.lang.Object implements java.lang.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. This is optimized for sequential access rather than direct access.
- 
- 
Constructor SummaryConstructors Constructor Description ImmutableList()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <T> ImmutableList<T>empty()Return an empty listbooleanequals(java.lang.Object o)Test whether two lists are equalabstract Thead()Get the first item in the listabstract booleanisEmpty()Ask whether the list is emptyjava.util.Iterator<T>iterator()Get an iterator over the elements of the listImmutableList<T>prepend(T element)Return a list with a new item added at the startImmutableList<T>reverse()Return a list with the contents of this list in reverse orderintsize()Get the size of the list (the number of items).abstract ImmutableList<T>tail()Get all items in the list other than the firstjava.lang.StringtoString()Return a string representation of the list contents
 
- 
- 
- 
Method Detail- 
emptypublic static <T> ImmutableList<T> empty() Return an empty list- Type Parameters:
- T- the nominal item type of the list elements
- Returns:
- an empty list
 
 - 
headpublic abstract T head() Get the first item in the list- Returns:
- the first item in the list
 
 - 
tailpublic abstract ImmutableList<T> tail() Get all items in the list other than the first- Returns:
- a list containing all items except the first
 
 - 
isEmptypublic abstract boolean isEmpty() Ask whether the list is empty- Returns:
- true if and only if the list contains no items
 
 - 
sizepublic 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.
 
 - 
prependpublic ImmutableList<T> prepend(T element) 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
 
 - 
equalspublic boolean equals(java.lang.Object o) Test whether two lists are equal- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- the other list
- Returns:
- true if the other object is an instance of this ImmutableList class, and the elements of the two lists are pairwise equal.
 
 - 
iteratorpublic java.util.Iterator<T> iterator() Get an iterator over the elements of the list- Specified by:
- iteratorin interface- java.lang.Iterable<T>
- Returns:
- an iterator over the list
 
 - 
toStringpublic java.lang.String toString() Return a string representation of the list contents- Overrides:
- toStringin class- java.lang.Object
- Returns:
- a string in the form "[item1, item2, ...]"
 
 - 
reversepublic ImmutableList<T> reverse() Return a list with the contents of this list in reverse order- Returns:
- the reversed list
 
 
- 
 
-