Class ImmutableArrayItem
java.lang.Object
net.sf.saxon.ma.arrays.ArrayItem
net.sf.saxon.ma.arrays.AbstractArrayItem
net.sf.saxon.ma.arrays.ImmutableArrayItem
- All Implemented Interfaces:
Callable, Function, GroundedValue, Item, Sequence
Implementation of ArrayItem backed by a persistent immutable array, so that operations
that "update" the array do not have to copy the whole array
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the number of members in the arrayConcatenate this array with anotherget(int index) Get a member of the arrayinsert(int position, GroundedValue member) Insert a new member into an arraybooleanisEmpty()Ask whether the array is emptymembers()Get the list of all members of the arrayput(int index, GroundedValue newValue) Replace a member of the arrayremove(int index) Remove a member from the arrayremoveSeveral(IntSet positions) Remove zero or more members from the arraysubArray(int start, int end) Get a subarray given a start and end positionMethods inherited from class AbstractArrayItem
atomize, call, deepEquals, effectiveBooleanValue, export, getAnnotations, getArity, getDescription, getFunctionItemType, getFunctionName, getMemberType, getOperandRoles, getUnicodeStringValue, isTrustedResultType, makeNewContext, toStringMethods inherited from class ArrayItem
getGenre, getSerialNumber, isArray, isMap, toShortStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Function
isSequenceVariadicMethods inherited from interface GroundedValue
asIterable, concatenate, containsNode, materializeMethods inherited from interface Item
getLength, getStringValue, head, isStreamed, itemAt, iterate, reduce, subsequenceMethods inherited from interface Sequence
makeRepeatable
-
Constructor Details
-
ImmutableArrayItem
-
-
Method Details
-
get
Get a member of the array- Specified by:
getin classArrayItem- Parameters:
index- the position of the member to retrieve (zero-based)- Returns:
- the value at the given position.
- Throws:
IndexOutOfBoundsException- if the index is out of range
-
put
Replace a member of the array- Specified by:
putin classArrayItem- Parameters:
index- the position of the member to replace (zero-based)newValue- the replacement value- Returns:
- the value at the given position.
- Throws:
IndexOutOfBoundsException- if the index is out of range
-
insert
Insert a new member into an array- Specified by:
insertin classArrayItem- Parameters:
position- the 0-based position that the new item will assumemember- the new member to be inserted- Returns:
- a new array item with the new member inserted
- Throws:
IndexOutOfBoundsException- if position is out of range
-
arrayLength
public int arrayLength()Get the number of members in the arrayNote: the
method always returns 1, because an array is an item- Specified by:
arrayLengthin classArrayItem- Returns:
- the number of members in this array.
-
isEmpty
-
members
Get the list of all members of the array -
subArray
Get a subarray given a start and end position- Specified by:
subArrayin classArrayItem- Parameters:
start- the start position (zero based)end- the end position (the position of the first item not to be returned) (zero based)- Returns:
- a new array item containing the sub-array
- Throws:
IndexOutOfBoundsException- if start, or start+end, is out of range
-
concat
Concatenate this array with another -
remove
Remove a member from the array- Specified by:
removein classArrayItem- Parameters:
index- the position of the member to be removed (zero-based)- Returns:
- a new array in which the requested member has been removed.
- Throws:
IndexOutOfBoundsException- if index is out of range
-
removeSeveral
Remove zero or more members from the array- Specified by:
removeSeveralin classArrayItem- Parameters:
positions- the positions of the members to be removed (zero-based). A value that is out of range is ignored.- Returns:
- a new array in which the requested member has been removed
-