Package net.sf.saxon.ma.parray
Class ImmList2<E>
- java.lang.Object
-
- net.sf.saxon.ma.parray.ImmList<E>
-
- net.sf.saxon.ma.parray.ImmList2<E>
-
- Type Parameters:
E- the type of the elements of the list
- All Implemented Interfaces:
java.lang.Iterable<E>
public class ImmList2<E> extends ImmList<E>
Implementation of an immutable list of arbitrary length, implemented as a binary tree
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmList<E>append(E member)Append an element at the end of the listImmList<E>appendList(ImmList<E> members)Append multiple elements at the end of the listEget(int index)Get the element at a given indexImmList<E>insert(int index, E member)Insert an element at a given positionbooleanisEmpty()Ask if the list is emptyjava.util.Iterator<E>iterator()protected ImmList<E>rebalance()Return a list containing the same elements as this list, but optimized for efficient accessImmList<E>remove(int index)Remove the member at a given positionImmList<E>replace(int index, E member)Replace the element at a given indexintsize()Get the size of the listImmList<E>subList(int start, int end)Return a sub-sequence with a given start and end position-
Methods inherited from class net.sf.saxon.ma.parray.ImmList
empty, fromList, head, outOfBounds, pair, singleton, tail
-
-
-
-
Method Detail
-
get
public E get(int index)
Description copied from class:ImmListGet the element at a given index
-
size
public int size()
Description copied from class:ImmListGet the size of the list
-
isEmpty
public boolean isEmpty()
Description copied from class:ImmListAsk if the list is empty
-
replace
public ImmList<E> replace(int index, E member)
Description copied from class:ImmListReplace the element at a given index
-
insert
public ImmList<E> insert(int index, E member)
Description copied from class:ImmListInsert an element at a given position- Specified by:
insertin classImmList<E>- Parameters:
index- the position (zero-based) for the insertion. The new element will be inserted before the existing element at this position. If the index is equal to the list size, the new element is inserted at the end.member- the new member to be included in the new list- Returns:
- a new list, identical to the old except for the addition of one member
-
append
public ImmList<E> append(E member)
Description copied from class:ImmListAppend an element at the end of the list
-
appendList
public ImmList<E> appendList(ImmList<E> members)
Description copied from class:ImmListAppend multiple elements at the end of the list- Specified by:
appendListin classImmList<E>- Parameters:
members- the new members to be included in the new list- Returns:
- a new list, identical to the old except for the addition of new members
-
remove
public ImmList<E> remove(int index)
Description copied from class:ImmListRemove the member at a given position
-
subList
public ImmList<E> subList(int start, int end)
Description copied from class:ImmListReturn a sub-sequence with a given start and end position- Specified by:
subListin classImmList<E>- Parameters:
start- the zero-based index position of the first member to be extractedend- the zero-based index position of the first member after the sub-sequence to be extracted- Returns:
- a new list containing the elements from the specified range of positions
-
iterator
public java.util.Iterator<E> iterator()
-
-