Class SimpleVector<E>
- All Implemented Interfaces:
BoundedHashable
,Array<E>
,AVector<E>
,Consumable
,Sequence<E>
,Externalizable
,Serializable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
,SequencedCollection<E>
- Direct Known Subclasses:
AbstractCharVector
,BitVector
,F32Vector
,F64Vector
,FVector
,Nodes.NodeVector
,PrimIntegerVector
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.)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final long
protected static final long
protected long
static final int
protected static final long
protected static final long
protected static final long
protected static final long
Fields inherited from class gnu.lists.AbstractSequence
noInts
Fields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
See java.util.List.boolean
See java.util.Collection.protected int
Add a value at a specified Pos.protected void
addSpace
(int index, int count) Insert count unspecified elements at index.protected void
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
void
protected void
gapReserve
(int where, int needed) protected final void
gapReserveGeneric
(int where, int needed) protected abstract Object
abstract int
protected final int
protected final int
protected final int
protected final int
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 final int
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 final boolean
The values arebuffer[0 <: size] ++ buffer[gapEnd <: ]
, where gapEnd = size + offsetboolean
protected final boolean
The values arebuffer[offset <: offset+size]
.protected final boolean
If isSimple(), the values are all the values of the buffer.protected abstract SimpleVector
newInstance
(int newSize) void
protected abstract void
protected final void
setGapBounds
(int gapStart, int gapEnd) protected final void
setGapBounds
(int gapStart, int gapEnd, long flags) protected final void
setInfoField
(int size, int offset, long flags) void
void
shift
(int srcStart, int dstStart, int count) int
size()
See java.util.List.protected int
vsize()
void
Methods inherited from class gnu.lists.AbstractSequence
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, unsupportedException
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface gnu.lists.Array
effectiveIndex, 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, setRaw
Methods inherited from interface gnu.kawa.util.BoundedHashable
boundedHash
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface gnu.lists.Consumable
consume
Methods inherited from interface java.util.List
addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, getFirst, getLast, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, subList, toArray, toArray
-
Field Details
-
info
protected long info -
MAX_GAP_SIZE
public static final int MAX_GAP_SIZE- See Also:
-
READ_ONLY_FLAG
protected static final long READ_ONLY_FLAG- See Also:
-
SHARED_FLAG
protected static final long SHARED_FLAG- See Also:
-
COPY_ON_WRITE
protected static final long COPY_ON_WRITE- See Also:
-
SUBRANGE_FLAG
protected static final long SUBRANGE_FLAG- See Also:
-
GAP_FLAG
protected static final long GAP_FLAG- See Also:
-
VERY_SIMPLE_FLAG
protected static final long VERY_SIMPLE_FLAG- See Also:
-
-
Constructor Details
-
SimpleVector
public SimpleVector()
-
-
Method Details
-
isVerySimple
protected final boolean isVerySimple()If isSimple(), the values are all the values of the buffer. In this case getSize() == getBufferLength(); -
isSubRange
protected final boolean isSubRange()The values arebuffer[offset <: offset+size]
. -
isGapBuffer
protected final boolean isGapBuffer()The values arebuffer[0 <: size] ++ buffer[gapEnd <: ]
, where gapEnd = size + offset -
setInfoField
protected final void setInfoField(int size, int offset, long flags) -
getGapStart
protected final int getGapStart() -
getGapEnd
protected final int getGapEnd() -
getGapSize
protected final int getGapSize() -
setGapBounds
protected final void setGapBounds(int gapStart, int gapEnd, long flags) -
setGapBounds
protected final void setGapBounds(int gapStart, int gapEnd) -
getSizeBits
protected final int getSizeBits() -
getOffsetBits
protected final int getOffsetBits() -
isReadOnly
public boolean isReadOnly() -
setReadOnly
public void setReadOnly() -
size
public int size()Description copied from interface:Sequence
See java.util.List. -
vsize
protected int vsize() -
effectiveIndex
public int effectiveIndex(int index) - Specified by:
effectiveIndex
in interfaceArray<E>
- Overrides:
effectiveIndex
in classAbstractSequence<E>
-
gapReserve
protected void gapReserve(int where, int needed) -
gapReserveGeneric
protected final void gapReserveGeneric(int where, int needed) -
setBuffer
- Overrides:
setBuffer
in classAbstractSequence<E>
-
getBufferLength
public abstract int getBufferLength() -
copyBuffer
public abstract void copyBuffer(int length) -
newInstance
-
asImmutable
- Specified by:
asImmutable
in interfaceArray<E>
- Overrides:
asImmutable
in classAbstractSequence<E>
-
checkCanWrite
protected void checkCanWrite()- Overrides:
checkCanWrite
in classAbstractSequence<E>
-
doCopyOnWrite
protected void doCopyOnWrite(int sz) -
getSegment
public long getSegment(int index) Get sub-range of this vector, starting at given index.- Returns:
(size<<32)|where
such thatget(i)
isdata[where]
;get(i+1)
isdata[where+1]
; untilget(i+size-1)
. Thesize
is at least 1 (unlessindex==size()
), but we try to do better.
-
getSegment
public int getSegment(int index, int len) -
getSegmentReadOnly
public int getSegmentReadOnly(int start, int len) -
isAfterPos
protected boolean isAfterPos(int ipos) Description copied from class:AbstractSequence
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?- Overrides:
isAfterPos
in classAbstractSequence<E>
-
getBuffer
-
getRowMajor
- Specified by:
getRowMajor
in interfaceArray<E>
- Overrides:
getRowMajor
in classAbstractSequence<E>
-
forEach
-
fill
-
shift
public void shift(int srcStart, int dstStart, int count) -
add
Description copied from class:AbstractSequence
See java.util.Collection.- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceList<E>
- Overrides:
add
in classAbstractSequence<E>
-
add
Description copied from class:AbstractSequence
See java.util.List. -
addPos
Description copied from class:AbstractSequence
Add a value at a specified Pos.- Overrides:
addPos
in classAbstractSequence<E>
- Returns:
- the updated Pos, which is after the inserted value..
-
addSpace
protected void addSpace(int index, int count) Insert count unspecified elements at index. -
delete
public void delete(int start, int end) -
clearBuffer
protected abstract void clearBuffer(int start, int count) -
toDataArray
-
getTag
This is convenience hack for printing "uniform vectors" (srfi 4). It may go away without notice! -
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-