|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.text.GapVector
An implementation of a gapped buffer similar to that used by emacs. The underlying storage is a java array of some type, which is known only by the subclass of this class. The array has a gap somewhere. The gap is moved to the location of changes to take advantage of common behavior where most changes occur in the same location. Changes that occur at a gap boundary are generally cheap and moving the gap is generally cheaper than moving the array contents directly to accomodate the change.
GapContent
Field Summary | |
private Object |
array
The array of items. |
private int |
g0
start of gap in the array |
private int |
g1
end of gap in the array |
Constructor Summary | |
GapVector()
Creates a new GapVector object. |
|
GapVector(int initialLength)
Creates a new GapVector object, with the initial size specified. |
Method Summary | |
protected abstract Object |
allocateArray(int len)
Allocate an array to store items of the type appropriate (which is determined by the subclass). |
(package private) void |
close(int position,
int nItems)
Delete nItems at position. |
protected Object |
getArray()
Access to the array. |
protected abstract int |
getArrayLength()
Get the length of the allocated array |
protected int |
getGapEnd()
Access to the end of the gap. |
protected int |
getGapStart()
Access to the start of the gap. |
(package private) int |
open(int position,
int nItems)
Make space for the given number of items at the given location. |
protected void |
replace(int position,
int rmSize,
Object addItems,
int addSize)
Replace the given logical position in the storage with the given new items. |
(package private) void |
resize(int nsize)
resize the underlying storage array to the given new size |
protected void |
shiftEnd(int newSize)
Make the gap bigger, moving any necessary data and updating the appropriate marks |
protected void |
shiftGap(int newGapStart)
Move the start of the gap to a new location, without changing the size of the gap. |
protected void |
shiftGapEndUp(int newGapEnd)
Adjust the gap end upward. |
protected void |
shiftGapStartDown(int newGapStart)
Adjust the gap end downward. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private Object array
private int g0
private int g1
Constructor Detail |
public GapVector()
public GapVector(int initialLength)
initialLength
- the initial sizeMethod Detail |
protected abstract Object allocateArray(int len)
protected abstract int getArrayLength()
protected final Object getArray()
protected final int getGapStart()
protected final int getGapEnd()
protected void replace(int position, int rmSize, Object addItems, int addSize)
position
- the location to make the replacement. This
is not the location in the underlying storage array, but
the location in the contiguous space being modeled.rmSize
- the number of items to removeaddItems
- the new items to place in storage.void close(int position, int nItems)
int open(int position, int nItems)
void resize(int nsize)
protected void shiftEnd(int newSize)
protected void shiftGap(int newGapStart)
protected void shiftGapStartDown(int newGapStart)
protected void shiftGapEndUp(int newGapEnd)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |