gnu.lists

Class GapVector

public class GapVector extends AbstractSequence implements Sequence

An array with a gap in the middle, allowing efficient insert and delete. The actual storage is delegated to a SimpleVector, so the element type depends on the sub-class of SimpleVector used.
Field Summary
SimpleVectorbase
intgapEnd
intgapStart
Constructor Summary
GapVector(SimpleVector base)
protected GapVector()
Method Summary
voidadd(int index, Object o)
protected intaddPos(int ipos, Object value)
voidconsumePosRange(int iposStart, int iposEnd, Consumer out)
intcreatePos(int index, boolean isAfter)
voidfill(Object value)
voidfillPosRange(int fromPos, int toPos, Object value)
protected voidgapReserve(int size)
Make sure gap is at least 'size' elements long.
protected voidgapReserve(int where, int size)
Adjust gap to 'where', and make sure it is least `size' elements long.
Objectget(int index)
intgetNextKind(int ipos)
intgetSegment(int where, int len)
If needed, move the gap so the given segment is contiguous.
booleanhasNext(int ipos)
protected booleanisAfterPos(int ipos)
protected intnextIndex(int ipos)
protected voidremovePosRange(int ipos0, int ipos1)
Objectset(int index, Object value)
protected voidshiftGap(int newGapStart)
intsize()

Field Detail

base

public SimpleVector base

gapEnd

public int gapEnd

gapStart

public int gapStart

Constructor Detail

GapVector

public GapVector(SimpleVector base)

GapVector

protected GapVector()

Method Detail

add

public void add(int index, Object o)

addPos

protected int addPos(int ipos, Object value)

consumePosRange

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

createPos

public int createPos(int index, boolean isAfter)

fill

public void fill(Object value)

fillPosRange

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

gapReserve

protected void gapReserve(int size)
Make sure gap is at least 'size' elements long.

gapReserve

protected void gapReserve(int where, int size)
Adjust gap to 'where', and make sure it is least `size' elements long.

get

public Object get(int index)

getNextKind

public int getNextKind(int ipos)

getSegment

public int getSegment(int where, int len)
If needed, move the gap so the given segment is contiguous.

Returns: the offset in the base array containing the segment, or -1 if the parameters are bad.

hasNext

public boolean hasNext(int ipos)

isAfterPos

protected boolean isAfterPos(int ipos)

nextIndex

protected int nextIndex(int ipos)

removePosRange

protected void removePosRange(int ipos0, int ipos1)

set

public Object set(int index, Object value)

shiftGap

protected void shiftGap(int newGapStart)

size

public int size()