net.sf.saxon.om

Class ReverseArrayIterator

public final class ReverseArrayIterator extends Object implements AxisIterator, ReversibleIterator, LookaheadIterator, LastPositionFinder

ReverseArrayIterator is used to enumerate items held in an array in reverse order.

Author: Michael H. Kay

Field Summary
Itemcurrent
intend
intindex
Item[]items
intstart
Constructor Summary
ReverseArrayIterator(Item[] items, int start, int end)
Create an iterator a slice of an array
Method Summary
Itemcurrent()
SequenceIteratorgetAnother()
intgetLastPosition()
intgetProperties()
Get properties of this iterator, as a bit-significant integer.
SequenceIteratorgetReverseIterator()
Get an iterator that processes the same items in reverse order.
booleanhasNext()
Determine whether there are more items to come.
Itemnext()
intposition()

Field Detail

current

Item current

end

int end

index

int index

items

Item[] items

start

int start

Constructor Detail

ReverseArrayIterator

public ReverseArrayIterator(Item[] items, int start, int end)
Create an iterator a slice of an array

Parameters: items The array of items start The first item in the array to be be used (this will be the last one in the resulting iteration). Zero-based. end The item after the last one in the array to be used (this will be the first one to be returned by the iterator). Zero-based.

Method Detail

current

public Item current()

getAnother

public SequenceIterator getAnother()

getLastPosition

public int getLastPosition()

getProperties

public int getProperties()
Get properties of this iterator, as a bit-significant integer.

Returns: the properties of this iterator. This will be some combination of properties such as GROUNDED, LAST_POSITION_FINDER, and LOOKAHEAD. It is always acceptable to return the value zero, indicating that there are no known special properties. It is acceptable for the properties of the iterator to change depending on its state.

getReverseIterator

public SequenceIterator getReverseIterator()
Get an iterator that processes the same items in reverse order. Since this iterator is processing the items backwards, this method returns an ArrayIterator that processes them forwards.

Returns: a new ArrayIterator

hasNext

public boolean hasNext()
Determine whether there are more items to come. Note that this operation is stateless and it is not necessary (or usual) to call it before calling next(). It is used only when there is an explicit need to tell if we are at the last element.

Returns: true if there are more items in the sequence

next

public Item next()

position

public int position()