public class GapTextStore extends Object implements ITextStore
Performance: Typing-style changes perform in constant time unless re-allocation
becomes necessary. Generally, a change that does not cause re-allocation will cause at most one
arraycopy operation of a length of
about d, where d is the distance from the previous change. Let a(x)
be the algorithmic performance of an
arraycopy operation of the length x,
then such a change then performs in O(a(x)),
get(int, length) performs in O(a(length)),
get(int) in O(1).
How frequently the array needs re-allocation is controlled by the constructor parameters.
This class is not intended to be subclassed.
for a copy-on-write text store wrapper
|Constructor and Description|
Equivalent to new GapTextStore(256, 4096, 0.1f).
Creates an empty text store that uses re-allocation thresholds relative to the content length.
|Modifier and Type||Method and Description|
Returns the character at the specified offset.
Returns the text of the specified character range.
Returns a copy of the content of this text store.
Returns the end index of the gap managed by this text store.
Returns the start index of the gap managed by this text store.
Returns number of characters stored in this text store.
Replaces the specified character range with the given text.
Replace the content of the text store with the given text.
@Deprecated public GapTextStore(int lowWatermark, int highWatermark)
GapTextStore(int, int, float)instead
lowWatermark- unused - at the lower bound, the array is only resized when the content does not fit
highWatermark- if the gap is ever larger than this, it will automatically be shrunken (>= 0)
public GapTextStore(int minSize, int maxSize, float maxGapFactor)
[0, maxGapFactor]. When re-allocation occurs, the array is sized such that the gap factor is
0.5 * maxGapFactor. The gap size computed in this manner is bounded by the
0 creates a text store that never has a gap
at all (if
minSize is 0); a
creates a text store that doubles its size with every re-allocation and that never shrinks.
maxSize parameters are absolute bounds to the
allocated gap size. Use
minSize to avoid frequent re-allocation for small
maxSize to avoid a huge gap being allocated for large
minSize- the minimum gap size to allocate (>= 0; use 0 for no minimum)
maxSize- the maximum gap size to allocate (>= minSize; use
Integer.MAX_VALUEfor no maximum)
maxGapFactor- is the maximum fraction of the array that is occupied by the gap (
0 <= maxGapFactor <= 1)
public final char get(int offset)
public final String get(int offset, int length)
public final int getLength()
public final void set(String text)
replace(0, getLength(), text.
public final void replace(int offset, int length, String text)
replace(getLength(), 0, "some text")is a valid call and appends text to the end of the text store.
protected String getContentAsString()
protected int getGapStartIndex()
protected int getGapEndIndex()
Copyright (c) 2000, 2017 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.