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 longprotected static final longprotected longstatic final intprotected static final longprotected static final longprotected static final longprotected static final longFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSee java.util.List.booleanSee java.util.Collection.protected intAdd a value at a specified Pos.protected voidaddSpace(int index, int count) Insert count unspecified elements at index.protected voidprotected abstract voidclearBuffer(int start, int count) abstract voidcopyBuffer(int length) voiddelete(int start, int end) protected voiddoCopyOnWrite(int sz) inteffectiveIndex(int index) voidvoidprotected voidgapReserve(int where, int needed) protected final voidgapReserveGeneric(int where, int needed) protected abstract Objectabstract intprotected final intprotected final intprotected final intprotected final intgetRowMajor(int i) longgetSegment(int index) Get sub-range of this vector, starting at given index.intgetSegment(int index, int len) intgetSegmentReadOnly(int start, int len) protected final intgetTag()This is convenience hack for printing "uniform vectors" (srfi 4).protected booleanisAfterPos(int ipos) Tests whether the position has the "isAfter" property.protected final booleanThe values arebuffer[0 <: size] ++ buffer[gapEnd <: ], where gapEnd = size + offsetbooleanprotected final booleanThe values arebuffer[offset <: offset+size].protected final booleanIf isSimple(), the values are all the values of the buffer.protected abstract SimpleVectornewInstance(int newSize) voidprotected abstract voidprotected final voidsetGapBounds(int gapStart, int gapEnd) protected final voidsetGapBounds(int gapStart, int gapEnd, long flags) protected final voidsetInfoField(int size, int offset, long flags) voidvoidshift(int srcStart, int dstStart, int count) intsize()See java.util.List.protected intvsize()voidMethods 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, unsupportedExceptionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, setRawMethods 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
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:SequenceSee java.util.List. -
vsize
protected int vsize() -
effectiveIndex
public int effectiveIndex(int index) - Specified by:
effectiveIndexin interfaceArray<E>- Overrides:
effectiveIndexin classAbstractSequence<E>
-
gapReserve
protected void gapReserve(int where, int needed) -
gapReserveGeneric
protected final void gapReserveGeneric(int where, int needed) -
setBuffer
- Overrides:
setBufferin classAbstractSequence<E>
-
getBufferLength
public abstract int getBufferLength() -
copyBuffer
public abstract void copyBuffer(int length) -
newInstance
-
asImmutable
- Specified by:
asImmutablein interfaceArray<E>- Overrides:
asImmutablein classAbstractSequence<E>
-
checkCanWrite
protected void checkCanWrite()- Overrides:
checkCanWritein 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)|wheresuch thatget(i)isdata[where];get(i+1)isdata[where+1]; untilget(i+size-1). Thesizeis 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: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>
-
getBuffer
-
getRowMajor
- Specified by:
getRowMajorin interfaceArray<E>- Overrides:
getRowMajorin classAbstractSequence<E>
-
forEach
-
fill
-
shift
public void shift(int srcStart, int dstStart, int count) -
add
Description copied from class:AbstractSequenceSee java.util.Collection.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractSequence<E>
-
add
Description copied from class:AbstractSequenceSee java.util.List. -
addPos
Description copied from class:AbstractSequenceAdd a value at a specified Pos.- Overrides:
addPosin 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:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-