gnu.lists

Class SimpleVector

public abstract class SimpleVector extends AbstractSequence implements Sequence, Array

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).
Field Summary
intsize
The (current) number of elements.
Method Summary
booleanadd(Object o)
voidadd(int index, Object o)
booleanaddAll(int index, Collection c)
protected intaddPos(int ipos, Object value)
voidclear()
protected abstract voidclearBuffer(int start, int count)
protected static intcompareToInt(SimpleVector v1, SimpleVector v2)
protected static intcompareToLong(SimpleVector v1, SimpleVector v2)
voidconsume(int start, int length, Consumer out)
booleanconsumeNext(int ipos, Consumer out)
voidconsumePosRange(int iposStart, int iposEnd, Consumer out)
intcreatePos(int index, boolean isAfter)
voidfill(Object value)
voidfill(int fromIndex, int toIndex, Object value)
voidfillPosRange(int fromPos, int toPos, Object value)
Objectget(int index)
protected abstract ObjectgetBuffer()
protected abstract ObjectgetBuffer(int index)
abstract intgetBufferLength()
Get the allocated length of the data buffer.
intgetElementKind()
intgetNextKind(int ipos)
ObjectgetPosNext(int ipos)
ObjectgetRowMajor(int i)
StringgetTag()
This is convenience hack for printing "uniform vectors" (srfi 4).
intintAt(int index)
intintAtBuffer(int index)
protected booleanisAfterPos(int ipos)
longlongAt(int index)
longlongAtBuffer(int index)
protected intnextIndex(int ipos)
intnextPos(int ipos)
Objectremove(int index)
booleanremove(Object o)
booleanremoveAll(Collection c)
voidremovePos(int ipos, int count)
protected voidremovePosRange(int ipos0, int ipos1)
booleanretainAll(Collection c)
Objectset(int index, Object value)
protected abstract ObjectsetBuffer(int index, Object value)
abstract voidsetBufferLength(int length)
voidsetSize(int size)
Set the size to a specified value.
voidshift(int srcStart, int dstStart, int count)
intsize()
Arraytranspose(int[] lowBounds, int[] dimensions, int offset0, int[] factors)

Field Detail

size

public int size
The (current) number of elements. Must always have size() >= 0 && size() <= getBufferLength().

Method Detail

add

public boolean add(Object o)

add

public void add(int index, Object o)

addAll

public boolean addAll(int index, Collection c)

addPos

protected int addPos(int ipos, Object value)

clear

public void clear()

clearBuffer

protected abstract void clearBuffer(int start, int count)

compareToInt

protected static int compareToInt(SimpleVector v1, SimpleVector v2)

compareToLong

protected static int compareToLong(SimpleVector v1, SimpleVector v2)

consume

public void consume(int start, int length, Consumer out)

consumeNext

public boolean consumeNext(int ipos, Consumer out)

consumePosRange

public void consumePosRange(int iposStart, int iposEnd, Consumer out)

createPos

public int createPos(int index, boolean isAfter)

fill

public void fill(Object value)

fill

public void fill(int fromIndex, int toIndex, Object value)

fillPosRange

public void fillPosRange(int fromPos, int toPos, Object value)

get

public Object get(int index)

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()

getNextKind

public int getNextKind(int ipos)

getPosNext

public Object getPosNext(int ipos)

getRowMajor

public Object getRowMajor(int i)

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)

longAt

public long longAt(int index)

longAtBuffer

public long longAtBuffer(int index)

nextIndex

protected int nextIndex(int ipos)

nextPos

public int nextPos(int ipos)

remove

public Object remove(int index)

remove

public boolean remove(Object o)

removeAll

public boolean removeAll(Collection c)

removePos

public void removePos(int ipos, int count)

removePosRange

protected void removePosRange(int ipos0, int ipos1)

retainAll

public boolean retainAll(Collection c)

set

public Object set(int index, Object value)

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)

size

public final int size()

transpose

public Array transpose(int[] lowBounds, int[] dimensions, int offset0, int[] factors)