| java.lang.Object gnu.lists.AbstractSequence
All known Subclasses: gnu.lists.GeneralArray, gnu.lists.ExtSequence, gnu.lists.TreeList, gnu.jemacs.buffer.Buffer, gnu.lists.SubSequence, gnu.lists.SimpleVector, gnu.lists.GapVector,
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 | |
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. | protected int | addPos(int ipos, Object value) Add a value at a specified Pos. | public void | clear() | public int | compare(int ipos1, int ipos2) Compare two positions, and indicate their relative order. | final public int | compare(SeqPosition i1, SeqPosition i2) | public static int | compare(AbstractSequence seq1, int pos1, AbstractSequence seq2, int pos2) This is used for the XML concept of "document order". | public void | consume(Consumer out) | public boolean | consumeNext(int ipos, Consumer out) Copy an element specified by a position pair to a Consumer.
if hasNext(ipos). | public void | consumePosRange(int iposStart, int iposEnd, Consumer out) | public boolean | contains(Object o) See java.util.List. | public boolean | containsAll(Collection c) See java.util.List. | public int | copyPos(int ipos) Make a copy of a position int.
For simple positions returns the argument.
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 cookie. | abstract public int | createPos(int index, boolean isAfter) Generate a position at a given index. | public int | createRelativePos(int pos, int delta, boolean isAfter) | final public Enumeration | elements() | public int | endPos() | public boolean | equals(int ipos1, int ipos2) Compare two positions, and indicate if they are the same position. | public boolean | equals(Object o) | public void | fill(Object value) | public void | fill(int fromIndex, int toIndex, Object value) | public void | fillPosRange(int fromPos, int toPos, Object value) | public int | firstAttributePos(int ipos) Like firstChildPos.
Problem: Should this stop before we get to children?
I think so, but that requires changes to TreeList. | public int | firstChildPos(int ipos) Get position before first child (of the element following position).
Parameters: ipos - parent position. | public int | firstChildPos(int ipos, ItemPredicate predicate) | protected int | fromEndIndex(int ipos) | 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) Get the size of the (sub-) sequence containing a given position. | public int | getEffectiveIndex(int[] indexes) | protected int | getIndexDifference(int ipos1, int ipos0) Get offset of (ipos1) relative to (ipos0). | final public SeqPosition | getIterator() | public SeqPosition | getIterator(int index) | public SeqPosition | getIteratorAtPos(int ipos) | public int | getLowBound(int dim) | public int | getNextKind(int ipos) | public String | getNextTypeName(int ipos) | public Object | getNextTypeObject(int ipos) | public Object | getPosNext(int ipos) Get the element following the specified position.
Parameters: ipos - the specified position. | public Object | getPosPrevious(int ipos) Get the element before the specified position.
Parameters: ipos - the specified position. | public int | getSize(int dim) | protected boolean | gotoAttributesStart(TreePosition pos) | final public boolean | gotoChildrenStart(TreePosition pos) Set position before first child (of the element following position). | protected boolean | gotoParent(TreePosition pos) | public boolean | hasNext(int ipos) | protected boolean | hasPrevious(int ipos) Called by SeqPosition.hasPrevious. | public int | hashCode() | public int | indexOf(Object o) See java.util.List. | protected boolean | isAfterPos(int ipos) Tests whether the position has the "isAfter" property.
I.e. | public boolean | isEmpty() | final public Iterator | iterator() | public int | lastIndexOf(Object o) See java.util.List. | final public ListIterator | listIterator() | final public ListIterator | listIterator(int index) | protected int | nextIndex(int ipos) Get the offset from the beginning corresponding to a position cookie. | final public int | nextIndex(SeqPosition pos) | public int | nextMatching(int startPos, ItemPredicate type, int endPos, boolean descend) Get next matching child or descendent (ignoring attributes).
Parameters: startPos - starting position Parameters: type - a test (predicate) to apply to selected elements Parameters: endPos - stop before endPos Parameters: descend - if true do depth-first traversal. | public int | nextPos(int ipos) Return the next position following the argument. | public int | parentPos(int ipos) Get position of parent.
Parameters: ipos - child position. | public int | previousPos(int ipos) Return the previous position following the argument. | public int | rank() | protected void | releasePos(int ipos) Reclaim any resources used by the given position int. | public Object | remove(int index) | public boolean | remove(Object o) | public boolean | removeAll(Collection c) | public void | removePos(int ipos, int count) Remove one or more elements. | protected void | removePosRange(int ipos0, int ipos1) Remove a range where each end-point is a position in a container. | public boolean | retainAll(Collection c) | public Object | set(int[] indexes, Object value) | public Object | set(int index, Object element) | protected void | setPosNext(int ipos, Object value) | protected void | setPosPrevious(int ipos, Object value) | abstract public int | size() See java.util.List. | public int | stableCompare(AbstractSequence other) This is used for the XML concept of "document order". | public int | startPos() | public List | subList(int fromIx, int toIx) | public Sequence | subSequence(SeqPosition start, SeqPosition end) | protected Sequence | subSequencePos(int ipos0, int ipos1) | public Object[] | toArray() | public Object[] | toArray(Object[] arr) | public void | toString(String sep, StringBuffer sbuf) | public String | toString() | protected RuntimeException | unsupported(String text) | public static RuntimeException | unsupportedException(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.
|
addPos | protected int addPos(int ipos, Object value)(Code) | | Add a value at a specified Pos.
the updated Pos, which is after the inserted value.. |
clear | public void clear()(Code) | | |
compare | public int compare(int ipos1, int ipos2)(Code) | | Compare two positions, and indicate their relative order.
|
compare | public static int compare(AbstractSequence seq1, int pos1, AbstractSequence seq2, int pos2)(Code) | | This is used for the XML concept of "document order".
It is overridden in gnu.xml.NodeTree for a more robust implementation.
|
consumeNext | public boolean consumeNext(int ipos, Consumer out)(Code) | | Copy an element specified by a position pair to a Consumer.
if hasNext(ipos). |
consumePosRange | public void consumePosRange(int iposStart, int iposEnd, Consumer out)(Code) | | |
contains | public boolean contains(Object o)(Code) | | See java.util.List.
|
copyPos | public int copyPos(int ipos)(Code) | | Make a copy of a position int.
For simple positions returns the argument.
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 cookie. In any case, the new position is initialized to
the same offset (and isAfter property) as the original.
Parameters: ipos - the position being copied. the new position |
createPos | abstract public int createPos(int index, boolean isAfter)(Code) | | Generate a position at a given index.
The result is a position cookie that must be free'd with releasePos.
Parameters: index - offset from beginning of desired position Parameters: isAfter - should the position have the isAfter property exception: IndexOutOfBoundsException - if index is out of bounds |
createRelativePos | public int createRelativePos(int pos, int delta, boolean isAfter)(Code) | | |
endPos | public int endPos()(Code) | | |
equals | public boolean equals(int ipos1, int ipos2)(Code) | | Compare two positions, and indicate if they are the same position.
|
fill | public void fill(int fromIndex, int toIndex, Object value)(Code) | | |
fillPosRange | public void fillPosRange(int fromPos, int toPos, Object value)(Code) | | |
firstAttributePos | public int firstAttributePos(int ipos)(Code) | | Like firstChildPos.
Problem: Should this stop before we get to children?
I think so, but that requires changes to TreeList.
|
firstChildPos | public int firstChildPos(int ipos)(Code) | | Get position before first child (of the element following position).
Parameters: ipos - parent position. It is not released by this method. non-zero position cookie if there is a child sequence(which might be empty); zero if current position is end of sequenceor following element is atomic (cannot have children). |
fromEndIndex | protected int fromEndIndex(int ipos)(Code) | | |
get | abstract public Object get(int index)(Code) | | See java.util.List.
|
getAttributeLength | public int getAttributeLength()(Code) | | |
getContainingSequenceSize | protected int getContainingSequenceSize(int ipos)(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, int ipos0)(Code) | | Get offset of (ipos1) relative to (ipos0).
|
getLowBound | public int getLowBound(int dim)(Code) | | |
getNextKind | public int getNextKind(int ipos)(Code) | | |
getNextTypeName | public String getNextTypeName(int ipos)(Code) | | |
getNextTypeObject | public Object getNextTypeObject(int ipos)(Code) | | |
getPosNext | public Object getPosNext(int ipos)(Code) | | Get the element following the specified position.
Parameters: ipos - the specified position. the following element, or eofValue if there is none.Called by SeqPosition.getNext. |
getPosPrevious | public Object getPosPrevious(int ipos)(Code) | | Get the element before the specified position.
Parameters: ipos - the specified position. the following element, or eofValue if there is none. |
getSize | public int getSize(int dim)(Code) | | |
gotoChildrenStart | final 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). |
hasNext | public boolean hasNext(int ipos)(Code) | | |
hasPrevious | protected boolean hasPrevious(int ipos)(Code) | | Called by SeqPosition.hasPrevious.
|
hashCode | public int hashCode()(Code) | | |
indexOf | public int indexOf(Object o)(Code) | | See java.util.List.
|
isAfterPos | protected boolean isAfterPos(int ipos)(Code) | | Tests 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?
|
isEmpty | public boolean isEmpty()(Code) | | |
lastIndexOf | public int lastIndexOf(Object o)(Code) | | See java.util.List.
|
nextIndex | protected int nextIndex(int ipos)(Code) | | Get the offset from the beginning corresponding to a position cookie.
|
nextMatching | public int nextMatching(int startPos, ItemPredicate type, int endPos, boolean descend)(Code) | | Get next matching child or descendent (ignoring attributes).
Parameters: startPos - starting position Parameters: type - a test (predicate) to apply to selected elements Parameters: endPos - stop before endPos Parameters: descend - if true do depth-first traversal. poistion of next match or 0 if none found |
nextPos | public int nextPos(int ipos)(Code) | | Return the next position following the argument.
The new position has the isAfter property.
The argument is implicitly released (as in releasePos).
Returns 0 if we are already at end of file.
|
parentPos | public int parentPos(int ipos)(Code) | | Get position of parent.
Parameters: ipos - child position. It is not released by this method. the p os of the parent, or endPos() is there is no known parent. |
previousPos | public int previousPos(int ipos)(Code) | | Return the previous position following the argument.
The new position has the isBefore property.
The argument is implicitly released (as in releasePos).
Returns -1 if we are already at beginning of file.
|
releasePos | protected void releasePos(int ipos)(Code) | | Reclaim any resources used by the given position int.
Parameters: ipos - the Pos being free'd. |
removePos | public void removePos(int ipos, int count)(Code) | | Remove one or more elements.
Parameters: ipos - 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). exception: java.lang.IndexOutOfBoundsException - if (count >= 0 ? (index < 0 || index + count > size()): (index + count < 0 || index > size())),where index == nextIndex(ipos, xpos). |
removePosRange | protected void removePosRange(int ipos0, int ipos1)(Code) | | Remove a range where each end-point is a position in a container.
Parameters: ipos0 - start of range, as a poistion Parameters: ipos1 - end of range exception: java.lang.IndexOutOfBoundsException - if nextIndex(ipos0) > nextIndex(ipos1)|| nextIndex(ipos0) < 0 || nextIndex(ipos1) > size() |
setPosNext | protected void setPosNext(int ipos, Object value)(Code) | | |
setPosPrevious | protected void setPosPrevious(int ipos, Object value)(Code) | | |
size | abstract public int size()(Code) | | See java.util.List.
|
stableCompare | public int stableCompare(AbstractSequence other)(Code) | | This is used for the XML concept of "document order".
|
startPos | public int startPos()(Code) | | |
subList | public List subList(int fromIx, int toIx)(Code) | | |
subSequencePos | protected Sequence subSequencePos(int ipos0, int ipos1)(Code) | | |
|
|