public abstract class SimpleVector<E> extends AbstractSequence<E> implements AVector<E>, java.io.Externalizable, java.util.RandomAccess
getBuffer().
(FUTURE: could be a wrapper around a String?)
The elements of the vector (viewed as a java.util.List)
are stored in order, in the array, in one of these modes:
Very-simple mode: All of elements of the data buffer are used.
Normally get(i) is the @code{i}'th element of the data buffer.
An exception: For a CharSequence (FString), the value of get(i)
is a Unicode code point, so it is found at offset computed by
Character.offsetByCodePoints(i).
Sub-range mode: The elements of this vector are a contiguous sub-range of the data buffer, given by a start offset and a size. This is used for creating a read-only sub-list with sharing of the data buffer. The original is made copy-on-write.
Gap-buffer mode: The elements of this vector are in two contiguous sub-range of the data buffer, one at the very start of the buffer, and one at the very end, with an unused gap between them. (The gap and either sub-range may be empty.)
| Modifier and Type | Field and Description |
|---|---|
protected static long |
COPY_ON_WRITE |
protected static long |
GAP_FLAG |
protected long |
info |
static int |
MAX_GAP_SIZE |
protected static long |
READ_ONLY_FLAG |
protected static long |
SHARED_FLAG |
protected static long |
SUBRANGE_FLAG |
protected static long |
VERY_SIMPLE_FLAG |
noIntsATTRIBUTE_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 and Description |
|---|
SimpleVector() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o)
See java.util.Collection.
|
void |
add(int index,
E o)
See java.util.List.
|
protected int |
addPos(int ipos,
E value)
Add a value at a specified Pos.
|
protected void |
addSpace(int index,
int count)
Insert count unspecified elements at index.
|
SimpleVector<E> |
asImmutable() |
protected void |
checkCanWrite() |
protected abstract void |
clearBuffer(int start,
int count) |
abstract void |
copyBuffer(int length) |
void |
delete(int start,
int end) |
protected void |
doCopyOnWrite(int sz) |
int |
effectiveIndex(int index) |
void |
fill(E value) |
void |
forEach(java.util.function.Consumer<? super E> action) |
protected void |
gapReserve(int where,
int needed) |
protected void |
gapReserveGeneric(int where,
int needed) |
protected abstract java.lang.Object |
getBuffer() |
abstract int |
getBufferLength() |
protected int |
getGapEnd() |
protected int |
getGapSize() |
protected int |
getGapStart() |
protected int |
getOffsetBits() |
E |
getRowMajor(int i) |
long |
getSegment(int index)
Get sub-range of this vector, starting at given index.
|
int |
getSegment(int index,
int len) |
int |
getSegmentReadOnly(int start,
int len) |
protected int |
getSizeBits() |
java.lang.String |
getTag()
This is convenience hack for printing "uniform vectors" (srfi 4).
|
protected boolean |
isAfterPos(int ipos)
Tests whether the position has the "isAfter" property.
|
protected boolean |
isGapBuffer()
The values are
buffer[0 <: size] ++ buffer[gapEnd <: ],
where gapEnd = size + offset |
boolean |
isReadOnly() |
protected boolean |
isSubRange()
The values are
buffer[offset <: offset+size]. |
protected boolean |
isVerySimple()
If isSimple(), the values are all the values of the buffer.
|
protected int |
length() |
protected abstract SimpleVector |
newInstance(int newSize) |
void |
readExternal(java.io.ObjectInput in) |
protected abstract void |
setBuffer(java.lang.Object obj) |
protected void |
setGapBounds(int gapStart,
int gapEnd) |
protected void |
setGapBounds(int gapStart,
int gapEnd,
long flags) |
protected void |
setInfoField(int size,
int offset,
long flags) |
void |
setReadOnly() |
void |
shift(int srcStart,
int dstStart,
int count) |
int |
size()
See java.util.List.
|
java.lang.Object |
toDataArray() |
void |
writeExternal(java.io.ObjectOutput out) |
addAll, addAll, badRank, boundedHash, checkRank, clear, compare, compare, compare, consume, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createPos, createRelativePos, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, endPos, equals, equals, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, get, get, get, getAttribute, getAttributeLength, getBooleanRaw, getByteRaw, getCharRaw, getContainingSequenceSize, getDoubleRaw, getElementKind, getFloatRaw, getIndexDifference, getInt, getInt, getInt, getInt, getInt, getIntRaw, getIterator, getIterator, getIteratorAtPos, getLongRaw, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getRaw, getShortRaw, getSize, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasNext, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setAt, setPosNext, setPosPrevious, setRaw, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, toString, unsupported, unsupportedExceptionclone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waiteffectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, get, get, get, get, get, getBooleanRaw, getByteRaw, getCharRaw, getDoubleRaw, getElementKind, getFloatRaw, getInt, getInt, getInt, getInt, getInt, getIntRaw, getLongRaw, getLowBound, getRaw, getShortRaw, getSize, getSize, isEmpty, rank, set, setRawaddAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArrayconsumeboundedHashprotected long info
public static final int MAX_GAP_SIZE
protected static final long READ_ONLY_FLAG
protected static final long SHARED_FLAG
protected static final long COPY_ON_WRITE
protected static final long SUBRANGE_FLAG
protected static final long GAP_FLAG
protected static final long VERY_SIMPLE_FLAG
protected final boolean isVerySimple()
protected final boolean isSubRange()
buffer[offset <: offset+size].protected final boolean isGapBuffer()
buffer[0 <: size] ++ buffer[gapEnd <: ],
where gapEnd = size + offsetprotected final void setInfoField(int size,
int offset,
long flags)
protected final int getGapStart()
protected final int getGapEnd()
protected final int getGapSize()
protected final void setGapBounds(int gapStart,
int gapEnd,
long flags)
protected final void setGapBounds(int gapStart,
int gapEnd)
protected final int getSizeBits()
protected final int getOffsetBits()
public boolean isReadOnly()
public void setReadOnly()
public int size()
Sequenceprotected int length()
public int effectiveIndex(int index)
effectiveIndex in interface Array<E>effectiveIndex in class AbstractSequence<E>protected void gapReserve(int where,
int needed)
protected final void gapReserveGeneric(int where,
int needed)
protected abstract void setBuffer(java.lang.Object obj)
setBuffer in class AbstractSequence<E>public abstract int getBufferLength()
public abstract void copyBuffer(int length)
protected abstract SimpleVector newInstance(int newSize)
public SimpleVector<E> asImmutable()
asImmutable in interface Array<E>asImmutable in class AbstractSequence<E>protected void checkCanWrite()
checkCanWrite in class AbstractSequence<E>protected void doCopyOnWrite(int sz)
public long getSegment(int index)
(size<<32)|where
such that get(i) is data[where];
get(i+1) is data[where+1];
until get(i+size-1).
The size is at least 1 (unless index==size()),
but we try to do better.public int getSegment(int index,
int len)
public int getSegmentReadOnly(int start,
int len)
protected boolean isAfterPos(int ipos)
AbstractSequenceisAfterPos in class AbstractSequence<E>protected abstract java.lang.Object getBuffer()
public E getRowMajor(int i)
getRowMajor in interface Array<E>getRowMajor in class AbstractSequence<E>public void forEach(java.util.function.Consumer<? super E> action)
forEach in interface java.lang.Iterable<E>public void fill(E value)
public void shift(int srcStart,
int dstStart,
int count)
public boolean add(E o)
AbstractSequenceadd in interface java.util.Collection<E>add in interface java.util.List<E>add in class AbstractSequence<E>public void add(int index,
E o)
AbstractSequenceadd in interface java.util.List<E>add in class AbstractSequence<E>protected int addPos(int ipos,
E value)
AbstractSequenceaddPos in class AbstractSequence<E>protected void addSpace(int index,
int count)
public void delete(int start,
int end)
protected abstract void clearBuffer(int start,
int count)
public java.lang.Object toDataArray()
public java.lang.String getTag()
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundException