A SimpleVector implement as a simple array plus a current size.
Methods with the word "Buffer" are methods which use the underlying
array, ignoring the 'size' field.
Can be used to implement CommonLisp simple vectors, but all simple
vectors are also adjustable (by re-allocating the buffer)
and have a fill pointer (the size field).
addAll
public boolean addAll(int index,
Collection c)
See java.util.Collection.
- addAll in interface AbstractSequence
addPos
protected int addPos(int ipos,
Object value)
Add a value at a specified Pos.
- addPos in interface AbstractSequence
- the updated Pos, which is after the inserted value..
clearBuffer
protected abstract void clearBuffer(int start,
int count)
consume
public void consume(int start,
int length,
Consumer out)
createPos
public int createPos(int index,
boolean isAfter)
Generate a position at a given index.
The result is a position cookie that must be free'd with releasePos.
- createPos in interface AbstractSequence
index
- offset from beginning of desired positionisAfter
- should the position have the isAfter property
getBuffer
protected abstract Object getBuffer()
getBuffer
protected abstract Object getBuffer(int index)
getBufferLength
public abstract int getBufferLength()
Get the allocated length of the data buffer.
getElementKind
public int getElementKind()
getPosNext
public Object getPosNext(int ipos)
Get the element following the specified position.
- getPosNext in interface AbstractSequence
ipos
- the specified position.
- the following element, or eofValue if there is none.
Called by SeqPosition.getNext.
getTag
public String getTag()
This is convenience hack for printing "uniform vectors" (srfi 4).
It may go away without notice!
intAt
public int intAt(int index)
intAtBuffer
public int intAtBuffer(int index)
isAfterPos
protected boolean isAfterPos(int ipos)
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?
- isAfterPos in interface AbstractSequence
longAt
public long longAt(int index)
longAtBuffer
public long longAtBuffer(int index)
nextIndex
protected int nextIndex(int ipos)
Get the offset from the beginning corresponding to a position cookie.
- nextIndex in interface AbstractSequence
nextPos
public int nextPos(int ipos)
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.
- nextPos in interface AbstractSequence
removePos
public void removePos(int ipos,
int count)
Remove one or more elements.
- removePos in interface AbstractSequence
ipos
- position where elements should be removedcount
- if non-negative, remove that number of elements
following (poses, posNumber); if negative the negative of the number
of elements to remove before (poses, posNumber).
removePosRange
protected void removePosRange(int ipos0,
int ipos1)
Remove a range where each end-point is a position in a container.
- removePosRange in interface AbstractSequence
ipos0
- start of range, as a poistionipos1
- end of range
setBuffer
protected abstract Object setBuffer(int index,
Object value)
setBufferLength
public abstract void setBufferLength(int length)
setSize
public void setSize(int size)
Set the size to a specified value.
The data buffer is grown if needed, with new elements set to zero/null. If
size is less than the current value, removed values are set to zero/null..
(This is because if you decrease and then increase the vector the
should be zero/null, and it is cleaner and better for gc to do the
zeroing/nulling on remove rather than add.)
If you need to change the size without setting removed elements to
zero/null (e.g. to change Common Lisp's fill pointer) set size directly.
shift
public void shift(int srcStart,
int dstStart,
int count)
transpose
public Array transpose(int[] lowBounds,
int[] dimensions,
int offset0,
int[] factors)
- transpose in interface Array