| java.lang.Object gnu.lists.AbstractSequence
All known Subclasses: gnu.lists.SubSequence, gnu.lists.TreeList, gnu.lists.LList, gnu.lists.SimpleVector,
AbstractSequence | abstract public class AbstractSequence (Code) | | An AbstractSequence is used to implement Sequences, and almost all
classes that extend AbstractSequence will implement Sequence.
However, AbstractSequence itself does not implement Sequence.
This is so we can use AbstractSequence to implement classes that are
"sequence-like" (such as multi-dimesnional arrays) but are not Sequences.
Additionally, a sequence may have zero or more attributes, which are
name-value pairs. A sequence may also have a named "type". These
extensions are to support XML functionality - it might be cleaner to
moe them to a sub-class of Sequence or some interface.
Many of the protected methods in Sequence (such as nextIndex) are
only intended to be called from SeqPosition or TreePosition, see those.
author: Per Bothner |
Method Summary | |
protected void | add(PositionContainer posSet, int posNumber, Object value) | public boolean | add(Object o) See java.util.Collection. | public void | add(int index, Object o) See java.util.List. | public boolean | addAll(Collection c) See java.util.Collection. | public boolean | addAll(int index, Collection c) See java.util.Collection. | public void | clear() | public int | compare(int ipos1, Object xpos1, int ipos2, Object xpos2) Compare two positions, and indicate their relative order. | final public int | compare(SeqPosition i1, SeqPosition i2) | protected void | consume(int iposStart, Object xposStart, int iposEnd, Object xposEnd, Consumer out) | public void | consume(Consumer out) | public boolean | consumeNext(int ipos, Object xpos, Consumer out) Copy an element specified by a position pair to a Consumer.
if hasNext(ipos, xpos). | public boolean | contains(Object o) See java.util.List. | public boolean | containsAll(Collection c) See java.util.List. | public void | copyPosition(int ipos, Object xpos, PositionContainer posSet, int posNumber) Make a copy of a position pair.
For simple positions this is a simple copy (assignment).
However, if the positions are magic cookies that are actively managed
by the sequence (as opposed to for example a simple index), then making
a copy may need to increment a reference count, or maybe allocate a
new position pair. | public Enumeration | elements() | public boolean | equals(int ipos1, Object xpos1, int ipos2, Object xpos2) Compare two positions, and indicate if the are the same position. | public boolean | equals(Object o) | public void | fill(Object value) | public void | fill(int fromIndex, int toIndex, Object value) | protected int | fromEndIndex(int ipos, Object xpos) | abstract public Object | get(int index) See java.util.List. | public Object | get(int[] indexes) | public Object | getAttribute(int index) | public int | getAttributeLength() | protected int | getContainingSequenceSize(int ipos, Object xpos) Get the size of the (sub-) sequence containing a given position. | public int | getEffectiveIndex(int[] indexes) | protected int | getIndexDifference(int ipos1, Object xpos1, int ipos0, Object xpos0) Get offset of (ipos1,xpos1) relative to (ipos0,xpos0). | public SeqPosition | getIterator() | protected Object | getNext(int ipos, Object xpos) Get the element following the specified position.
Parameters: ipos - integer part of the specified position. Parameters: xpos - Object part of the specified position. | public int | getNextKind(int ipos, Object xpos) | public String | getNextTypeName(int ipos, Object xpos) | public Object | getNextTypeObject(int ipos, Object xpos) | protected Object | getPrevious(int ipos, Object xpos) Get the element before the specified position.
Parameters: ipos - integer part of the specified position. Parameters: xpos - Object part of the specified position. | protected boolean | gotoAttributesStart(TreePosition pos) | public boolean | gotoChildrenStart(TreePosition pos) Set position before first child (of the element following position). | public boolean | gotoNext(PositionContainer posSet, int posNumber) Move forward one element position. | public boolean | gotoNext(SeqPosition pos) Potential optimization. | protected boolean | gotoParent(TreePosition pos) | protected boolean | gotoPrevious(PositionContainer posSet, int posNumber) Move backwards one element. | protected boolean | hasNext(int ipos, Object xpos) Called by SeqPosition.hasNext. | protected boolean | hasPrevious(int ipos, Object xpos) Called by SeqPosition.hasPrevious. | public int | hashCode() | public int | indexOf(Object o) See java.util.List. | protected boolean | isAfter(int ipos, Object xpos) Does the position pair have the "isAfter" property?
I.e. | public boolean | isEmpty() | public Iterator | iterator() | public int | lastIndexOf(Object o) See java.util.List. | public ListIterator | listIterator() | public ListIterator | listIterator(int index) | public void | makeEndPosition(SeqPosition pos) Set a position to the end of this sequence. | protected void | makeEndPosition(PositionContainer poses, int positionNumber) | final protected void | makePosition(int index, SeqPosition pos) | public void | makePosition(int index, boolean isAfter, SeqPosition pos) Generate a position at a given index. | abstract protected void | makePosition(int index, boolean isAfter, PositionContainer posSet, int posNumber) Generate a position at a given index.
Parameters: index - offset from beginning of desired position Parameters: isAfter - should the position have the isAfter property Parameters: posSet - where to store the generated position Parameters: posNumber - index in posSet for the generated position. | protected void | makeRelativePosition(int istart, Object xstart, int offset, boolean isAfter, PositionContainer posSet, int posNumber) Generate a position relative to an existing position.
Parameters: istart - int part of initial position Parameters: xstart - object part of initial position Parameters: offset - offset from (istart,xstart) of desired position Parameters: isAfter - should the position have the isAFter property Parameters: posSet - where to store the generated position Parameters: positionNumber - index in posSet for the generated position. | public void | makeStartPosition(SeqPosition pos) | protected void | makeStartPosition(PositionContainer poses, int positionNumber) Set a position to the start of this sequence. | protected int | nextIndex(int ipos, Object xpos) Get the offset from the beginning corresponding to a position pair. | final public int | nextIndex(SeqPosition pos) | public int | rank() | protected void | releasePosition(int ipos, Object xpos) Reclaim any resources used by the given position pair. | final protected void | releasePosition(SeqPosition pos) | protected void | releasePosition(PositionContainer posSet, int posNumber) | protected void | remove(int ipos, Object xpos, int count) Remove one or more elements.
Parameters: ipos - integer part of position where elements should be removed Parameters: xpos - object part of position where elements should be removed Parameters: count - if non-negative, remove that number of elementsfollowing (poses, posNumber); if negative the negative of the numberof elements to remove before (poses, posNumber). | protected void | remove(int ipos0, Object xpos0, int ipos1, Object xpos1) Remove a range where each end-point is a position in a container. | public Object | remove(int index) | public boolean | remove(Object o) | public boolean | removeAll(Collection c) | public boolean | retainAll(Collection c) | public Object | set(int[] indexes, Object value) | public Object | set(int index, Object element) | protected void | setNext(int ipos, Object xpos, Object value) | protected void | setPrevious(int ipos, Object xpos, Object value) | abstract public int | size() See java.util.List. | public List | subList(int fromIx, int toIx) | public Sequence | subSequence(SeqPosition start, SeqPosition end) | protected Sequence | subSequence(int ipos0, Object xpos0, int ipos1, Object xpos1) | public Object[] | toArray() | public Object[] | toArray(Object[] arr) | protected RuntimeException | unsupported(String text) |
add | public boolean add(Object o)(Code) | | See java.util.Collection.
|
add | public void add(int index, Object o)(Code) | | See java.util.List.
|
addAll | public boolean addAll(int index, Collection c)(Code) | | See java.util.Collection.
|
clear | public void clear()(Code) | | |
compare | public int compare(int ipos1, Object xpos1, int ipos2, Object xpos2)(Code) | | Compare two positions, and indicate their relative order.
|
consumeNext | public boolean consumeNext(int ipos, Object xpos, Consumer out)(Code) | | Copy an element specified by a position pair to a Consumer.
if hasNext(ipos, xpos). |
contains | public boolean contains(Object o)(Code) | | See java.util.List.
|
copyPosition | public void copyPosition(int ipos, Object xpos, PositionContainer posSet, int posNumber)(Code) | | Make a copy of a position pair.
For simple positions this is a simple copy (assignment).
However, if the positions are magic cookies that are actively managed
by the sequence (as opposed to for example a simple index), then making
a copy may need to increment a reference count, or maybe allocate a
new position pair. In any case, the new pair is initialized to the
same offset (and isAfter property) as the original.
Parameters: ipos - integer part of the position being copied. Parameters: xpos - Object part of the position being copied. Parameters: posSet - where to put the new copy Parameters: posNumber - which psoition in posSet that gets the copy. |
equals | public boolean equals(int ipos1, Object xpos1, int ipos2, Object xpos2)(Code) | | Compare two positions, and indicate if the are the same position.
|
fill | public void fill(int fromIndex, int toIndex, Object value)(Code) | | |
fromEndIndex | protected int fromEndIndex(int ipos, Object xpos)(Code) | | |
get | abstract public Object get(int index)(Code) | | See java.util.List.
|
getAttributeLength | public int getAttributeLength()(Code) | | |
getContainingSequenceSize | protected int getContainingSequenceSize(int ipos, Object xpos)(Code) | | Get the size of the (sub-) sequence containing a given position.
Normally the same as size(), but may be different if this Sequence
is a tree and the position points at an interior node.
|
getEffectiveIndex | public int getEffectiveIndex(int[] indexes)(Code) | | |
getIndexDifference | protected int getIndexDifference(int ipos1, Object xpos1, int ipos0, Object xpos0)(Code) | | Get offset of (ipos1,xpos1) relative to (ipos0,xpos0).
|
getNext | protected Object getNext(int ipos, Object xpos)(Code) | | Get the element following the specified position.
Parameters: ipos - integer part of the specified position. Parameters: xpos - Object part of the specified position. the following element, or eofValue if there is none.Called by SeqPosition.getNext. |
getNextKind | public int getNextKind(int ipos, Object xpos)(Code) | | |
getPrevious | protected Object getPrevious(int ipos, Object xpos)(Code) | | Get the element before the specified position.
Parameters: ipos - integer part of the specified position. Parameters: xpos - Object part of the specified position. the following element, or eofValue if there is none.Called by SeqPosition.getNext. |
gotoChildrenStart | public boolean gotoChildrenStart(TreePosition pos)(Code) | | Set position before first child (of the element following position).
true if there is a child sequence (which might be empty);false if current position is end of sequence or following elementis atomic (cannot have children). |
gotoNext | public boolean gotoNext(PositionContainer posSet, int posNumber)(Code) | | Move forward one element position.
true unless at end of sequence. |
gotoPrevious | protected boolean gotoPrevious(PositionContainer posSet, int posNumber)(Code) | | Move backwards one element.
false iff already at beginning. |
hasNext | protected boolean hasNext(int ipos, Object xpos)(Code) | | Called by SeqPosition.hasNext.
|
hasPrevious | protected boolean hasPrevious(int ipos, Object xpos)(Code) | | Called by SeqPosition.hasPrevious.
|
hashCode | public int hashCode()(Code) | | |
indexOf | public int indexOf(Object o)(Code) | | See java.util.List.
|
isAfter | protected boolean isAfter(int ipos, Object xpos)(Code) | | Does the position pair have the "isAfter" property?
I.e. if something is inserted at the position, will
the iterator end up being after the new data?
|
isEmpty | public boolean isEmpty()(Code) | | |
lastIndexOf | public int lastIndexOf(Object o)(Code) | | See java.util.List.
|
makeEndPosition | public void makeEndPosition(SeqPosition pos)(Code) | | Set a position to the end of this sequence.
|
makePosition | public void makePosition(int index, boolean isAfter, SeqPosition pos)(Code) | | Generate a position at a given index.
Parameters: index - offset from beginning of desired position Parameters: isAfter - should the position have the isAfter property Parameters: pos - where to store the generated positionThis old position should be already released, if needed. exception: IndexOutOfBoundsException - if index is out of bounds |
makePosition | abstract protected void makePosition(int index, boolean isAfter, PositionContainer posSet, int posNumber)(Code) | | Generate a position at a given index.
Parameters: index - offset from beginning of desired position Parameters: isAfter - should the position have the isAfter property Parameters: posSet - where to store the generated position Parameters: posNumber - index in posSet for the generated position. Any oldposition there should be alread released, if needed. exception: IndexOutOfBoundsException - if index is out of bounds |
makeRelativePosition | protected void makeRelativePosition(int istart, Object xstart, int offset, boolean isAfter, PositionContainer posSet, int posNumber)(Code) | | Generate a position relative to an existing position.
Parameters: istart - int part of initial position Parameters: xstart - object part of initial position Parameters: offset - offset from (istart,xstart) of desired position Parameters: isAfter - should the position have the isAFter property Parameters: posSet - where to store the generated position Parameters: positionNumber - index in posSet for the generated position. Anyold position there should be alread released, if needed. exception: IndexOutOfBoundsException - if resulting index is out of bounds |
makeStartPosition | protected void makeStartPosition(PositionContainer poses, int positionNumber)(Code) | | Set a position to the start of this sequence.
|
nextIndex | protected int nextIndex(int ipos, Object xpos)(Code) | | Get the offset from the beginning corresponding to a position pair.
Note default implementation only works for array-like sequences!
|
releasePosition | protected void releasePosition(int ipos, Object xpos)(Code) | | Reclaim any resources used by the given position pair.
Parameters: ipos - integer part of the position being free'd. Parameters: xpos - Object part of the position being free'd. |
remove | protected void remove(int ipos, Object xpos, int count)(Code) | | Remove one or more elements.
Parameters: ipos - integer part of position where elements should be removed Parameters: xpos - object part of position where elements should be removed Parameters: count - if non-negative, remove that number of elementsfollowing (poses, posNumber); if negative the negative of the numberof elements to remove before (poses, posNumber). number of elements actually removed (non-negative) exception: java.lang.IndexOutOfBoundsException - if (count >= 0 ? (index < 0 || index + count > size()): (index + count < 0 || index > size())),where index == nextIndex(ipos, xpos). |
remove | protected void remove(int ipos0, Object xpos0, int ipos1, Object xpos1)(Code) | | Remove a range where each end-point is a position in a container.
Parameters: ipos0 - integer part of start of range Parameters: xpos0 - object part of start of range Parameters: ipos1 - integer part of end of range Parameters: xpos1 - object part of end of range exception: java.lang.IndexOutOfBoundsException - if nextIndex(ipos0, xpos0) > nextIndex(ipos1, xpos1)|| nextIndex(ipos0, xpos0) < 0 || nextIndex(ipos1, xpos1) > size() |
size | abstract public int size()(Code) | | See java.util.List.
|
subList | public List subList(int fromIx, int toIx)(Code) | | |
|
|