public abstract class FlyOffsetGapList<E> extends GapList<E>
OffsetGapList
additionally supporting
flyweight (non-modifiable) elements.
modCount
Constructor and Description |
---|
FlyOffsetGapList() |
FlyOffsetGapList(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
protected void |
consistencyCheck(boolean checkElementLength)
Check consistency of this list.
|
void |
defaultInsertUpdate(int offset,
int length)
Inform the list that there was an insert done into an underlying storage
(e.g.
|
void |
defaultRemoveUpdate(int offset,
int length)
Inform the list that there was a removal done into an underlying storage
(e.g.
|
protected String |
dumpInternals() |
protected abstract int |
elementLength(E elem)
Get length of an element (assuming it has a length when it has
an offset).
|
protected int |
elementOffset(int index)
Get the offset of an element stored in the list at the given index.
|
protected int |
elementOrEndOffset(int indexOrSize)
Get the offset of an element stored in the list at the given index
like
FlyOffsetGapList.elementOffset(int) does or get end offset of the last element
if GapList.size() is passed as index parameter. |
protected abstract int |
elementRawOffset(E elem)
Get the raw offset of the given element currently stored in the list.
|
protected int |
findElementIndex(int offset)
Find an index of the first element at the given offset in the list
by using binary search.
|
protected abstract boolean |
isElementFlyweight(E elem)
Check whether the given element is flyweight and therefore skipped
during update operations.
|
protected void |
moveOffsetGap(int offset,
int index)
Move the offset gap so that it's on the requested offset.
|
protected int |
offset2Raw(int offset)
Convert the given offset into raw form suitable for storing in this list.
|
protected int |
offsetGapLength() |
protected int |
offsetGapStart() |
protected abstract void |
setElementRawOffset(E elem,
int rawOffset)
Set the raw offset of the given element currently stored in the list.
|
protected int |
startOffset()
Return base starting offset to which all the tokens contained in this list
are related.
|
protected void |
updateElementOffsetAdd(E elem)
This method updates element's offset (shifts it above offset gap if necessary)
before adding the element to the list.
|
protected void |
updateElementOffsetRemove(E elem)
This method updates element's offset (shifts it below offset gap if necessary)
before (or after) the element gets removed from the list.
|
protected void |
updateOffsetGapLength(int offsetGapLengthDelta)
Update the offset gap length by the given delta.
|
protected void |
updateOffsetGapStart(int offsetDelta)
Update the offset gap length by the given delta.
|
add, add, addAll, addAll, addAll, addAll, addArray, addArray, addArray, clear, clone, consistencyCheck, consistencyError, contains, copy, copyElements, copyElements, copyItems, dumpDetails, dumpElements, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, swap, toArray, toArray, toString, trimToSize
equals, hashCode, iterator, listIterator, listIterator, subList
containsAll, remove, removeAll, retainAll
finalize, getClass, notify, notifyAll, wait, wait, wait
addFirst, addLast, containsAll, copyOf, equals, getFirst, getLast, hashCode, iterator, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, subList
parallelStream, removeIf, stream, toArray
public FlyOffsetGapList()
public FlyOffsetGapList(int initialCapacity)
protected abstract int elementRawOffset(E elem)
elem
- element currently stored in the list.#raw2RelOffset(int)
to become the real offset.protected abstract void setElementRawOffset(E elem, int rawOffset)
elem
- element currently stored in the list.rawOffset
- raw offset to be stored in the given element.protected abstract boolean isElementFlyweight(E elem)
protected abstract int elementLength(E elem)
protected int startOffset()
protected final int elementOffset(int index)
FlyOffsetGapList.elementLength(Object)
and its sum
plus the first preceding non-flyweight element's offset is returned.
index
- of the element in the list.FlyOffsetGapList.startOffset()
.IndexOutOfBoundsException
- if index >= size() or lower than zeroprotected final int elementOrEndOffset(int indexOrSize)
FlyOffsetGapList.elementOffset(int)
does or get end offset of the last element
if GapList.size()
is passed as index parameter.indexOrSize
- index of the element in the list.
Index equal to size()
can be used to get end offset
of the last element.FlyOffsetGapList.startOffset()
.IndexOutOfBoundsException
- if index > size() or lower than zeropublic void defaultInsertUpdate(int offset, int length)
Subclasses can build their own way of updating and they are not required to use this method.
offset
- offset at which the insertion occurred. It should not include FlyOffsetGapList.startOffset()
.length
- length of the inserted area.public void defaultRemoveUpdate(int offset, int length)
Subclasses can build their own way of updating and they are not required to use this method.
offset
- offset at which the removal occurred. It should not include FlyOffsetGapList.startOffset()
.length
- length of the removed area.protected final void moveOffsetGap(int offset, int index)
Note: Improper use of this may logically damage offsets of the elements contained in the list.
offset
- offset to which the offsetGapStart
should be assigned. It should not include FlyOffsetGapList.startOffset()
.index
- index of the first element at the given offset in the list.
FlyOffsetGapList.findElementIndex(int)
.protected final int offsetGapStart()
protected final void updateOffsetGapStart(int offsetDelta)
Note: Improper use of this may logically damage offsets of the elements contained in the list.
protected final int offsetGapLength()
protected final void updateOffsetGapLength(int offsetGapLengthDelta)
Note: Improper use of this may logically damage offsets of the elements contained in the list.
protected final int findElementIndex(int offset)
offset
- offset of the element to be found. It should not include FlyOffsetGapList.startOffset()
.protected void updateElementOffsetAdd(E elem)
protected void updateElementOffsetRemove(E elem)
protected final int offset2Raw(int offset)
offset
- >=0 absolute offset that includes FlyOffsetGapList.startOffset()
.protected void consistencyCheck(boolean checkElementLength)
checkElementLength
- whether FlyOffsetGapList.elementLength(Object)
should be called to check lengths of the elements and verify
that the offsets are in concert with the offsets.protected String dumpInternals()
dumpInternals
in class GapList<E>