Package gnu.lists
Class SubSequence<E>
java.lang.Object
gnu.lists.AbstractSequence<E>
gnu.lists.SubSequence<E>
- All Implemented Interfaces:
BoundedHashable,Consumable,Sequence<E>,Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>
A sequence consisting of a sub-range of the elements of a base sequence.
The start and end positions are position triples (on the same sequence).
-
Field Summary
Fields inherited from class gnu.lists.AbstractSequence
noIntsFields inherited from interface gnu.lists.Sequence
ATTRIBUTE_VALUE, BOOLEAN_VALUE, CDATA_VALUE, CHAR_VALUE, COMMENT_VALUE, DOCUMENT_VALUE, DOUBLE_VALUE, ELEMENT_VALUE, EOF_VALUE, eofValue, FLOAT_VALUE, INT_S16_VALUE, INT_S32_VALUE, INT_S64_VALUE, INT_S8_VALUE, INT_U16_VALUE, INT_U32_VALUE, INT_U64_VALUE, INT_U8_VALUE, OBJECT_VALUE, PRIM_VALUE, PROCESSING_INSTRUCTION_VALUE, TEXT_BYTE_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionSubSequence(AbstractSequence<E> base) SubSequence(AbstractSequence<E> base, int startPos, int endPos) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()intcompare(int ipos1, int ipos2) Compare two positions, and indicate their relative order.intcreatePos(int offset, boolean isAfter) Generate a position at a given index.intcreateRelativePos(int pos, int offset, boolean isAfter) intendPos()voidfinalize()get(int index) See java.util.List.protected intgetIndexDifference(int ipos1, int ipos0) Get offset of (ipos1) relative to (ipos0).intgetNextKind(int ipos) getPosNext(int ipos) Get the element following the specified position.getPosPrevious(int ipos) Get the element before the specified position.protected booleanisAfterPos(int ipos) Tests whether the position has the "isAfter" property.protected intnextIndex(int ipos) Get the offset from the beginning corresponding to a position cookie.voidreleasePos(int ipos) Reclaim any resources used by the given position int.voidremovePosRange(int istart, int iend) Remove a range where each end-point is a position in a container.intsize()See java.util.List.intstartPos()subSequencePos(int ipos0, int ipos1) Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, asImmutable, badRank, boundedHash, checkCanWrite, checkRank, compare, compare, consume, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, get, get, getAttribute, getAttributeLength, getBooleanRaw, getByteRaw, getCharRaw, getContainingSequenceSize, getDoubleRaw, getElementKind, getFloatRaw, getInt, getInt, getInt, getInt, getInt, getIntRaw, getIterator, getIterator, getIteratorAtPos, getLongRaw, getLowBound, getNextTypeName, getNextTypeObject, getRaw, getRowMajor, getShortRaw, getSize, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasNext, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, remove, remove, removeAll, removePos, retainAll, set, set, setAt, setBuffer, setPosNext, setPosPrevious, setRaw, stableCompare, subList, subSequence, toArray, toArray, toString, toString, unsupported, unsupportedExceptionMethods inherited from interface gnu.kawa.util.BoundedHashable
boundedHashMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface gnu.lists.Consumable
consumeMethods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, contains, containsAll, equals, getFirst, getLast, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
SubSequence
public SubSequence() -
SubSequence
-
SubSequence
-
-
Method Details
-
get
Description copied from interface:SequenceSee java.util.List. -
size
public int size()Description copied from interface:SequenceSee java.util.List. -
removePosRange
public void removePosRange(int istart, int iend) Description copied from class:AbstractSequenceRemove a range where each end-point is a position in a container.- Overrides:
removePosRangein classAbstractSequence<E>- Parameters:
istart- start of range, as a poistioniend- end of range
-
isAfterPos
protected boolean isAfterPos(int ipos) Description copied from class:AbstractSequenceTests whether the position has the "isAfter" property. I.e. if something is inserted at the position, will the iterator end up being after the new data?- Overrides:
isAfterPosin classAbstractSequence<E>
-
createPos
public int createPos(int offset, boolean isAfter) Description copied from class:AbstractSequenceGenerate a position at a given index. The result is a position cookie that must be free'd with releasePos.- Overrides:
createPosin classAbstractSequence<E>- Parameters:
offset- offset from beginning of desired positionisAfter- should the position have the isAfter property
-
createRelativePos
public int createRelativePos(int pos, int offset, boolean isAfter) - Overrides:
createRelativePosin classAbstractSequence<E>
-
getIndexDifference
protected int getIndexDifference(int ipos1, int ipos0) Description copied from class:AbstractSequenceGet offset of (ipos1) relative to (ipos0).- Overrides:
getIndexDifferencein classAbstractSequence<E>
-
releasePos
public void releasePos(int ipos) Description copied from class:AbstractSequenceReclaim any resources used by the given position int.- Overrides:
releasePosin classAbstractSequence<E>- Parameters:
ipos- the Pos being free'd.
-
nextIndex
protected int nextIndex(int ipos) Description copied from class:AbstractSequenceGet the offset from the beginning corresponding to a position cookie.- Overrides:
nextIndexin classAbstractSequence<E>
-
compare
public int compare(int ipos1, int ipos2) Description copied from class:AbstractSequenceCompare two positions, and indicate their relative order.- Overrides:
comparein classAbstractSequence<E>
-
getPosNext
Description copied from class:AbstractSequenceGet the element following the specified position.- Overrides:
getPosNextin classAbstractSequence<E>- Parameters:
ipos- the specified position.- Returns:
- the following element, or eofValue if there is none. Called by SeqPosition.getNext. FIXME Should change eof handling so return type can be E.
-
getNextKind
public int getNextKind(int ipos) - Overrides:
getNextKindin classAbstractSequence<E>
-
startPos
public int startPos()- Overrides:
startPosin classAbstractSequence<E>
-
endPos
public int endPos()- Overrides:
endPosin classAbstractSequence<E>
-
getPosPrevious
Description copied from class:AbstractSequenceGet the element before the specified position.- Overrides:
getPosPreviousin classAbstractSequence<E>- Parameters:
ipos- the specified position.- Returns:
- the following element, or eofValue if there is none. FIXME Should change eof handling so return type can be E.
-
subSequencePos
- Overrides:
subSequencePosin classAbstractSequence<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classAbstractSequence<E>
-
finalize
public void finalize()
-