public class SegmentArray
extends java.lang.Object
'index <-> (start; end)'
and provides convenient way for working with them, e.g. find index by particular offset that
belongs to target (start; end)
segment etc.
Not thread-safe.Modifier and Type | Field and Description |
---|---|
protected static int |
INITIAL_SIZE |
protected int[] |
myEnds |
protected int |
mySegmentCount |
protected int[] |
myStarts |
Modifier | Constructor and Description |
---|---|
protected |
SegmentArray() |
Modifier and Type | Method and Description |
---|---|
void |
changeSegmentLength(int startIndex,
int change) |
int |
findSegmentIndex(int offset) |
int |
getLastValidOffset() |
int |
getSegmentCount() |
int |
getSegmentEnd(int index) |
int |
getSegmentStart(int index) |
protected static int [] |
insert(int [] array,
int [] insertArray,
int startIndex,
int insertLength,
int mySegmentCount) |
protected void |
insert(SegmentArray segmentArray,
int startIndex) |
protected int |
noSegmentsAvailable(int offset) |
protected int |
offsetOutOfRange(int offset,
int lastValidOffset) |
protected int [] |
remove(int [] array,
int startIndex,
int endIndex) |
void |
remove(int startIndex,
int endIndex) |
void |
removeAll() |
protected void |
replace(int startOffset,
SegmentArray data,
int len) |
protected int |
segmentNotFound(int offset,
int start) |
protected void |
setElementAt(int i,
int startOffset,
int endOffset) |
void |
shiftSegments(int startIndex,
int shift) |
protected int[] myStarts
protected int[] myEnds
protected int mySegmentCount
protected static final int INITIAL_SIZE
protected void setElementAt(int i, int startOffset, int endOffset)
protected void replace(int startOffset, SegmentArray data, int len)
protected int noSegmentsAvailable(int offset)
protected int offsetOutOfRange(int offset, int lastValidOffset)
public final int findSegmentIndex(int offset)
java.lang.IllegalStateException
- if a gap between segments is detected, or if there are no segments and an index for a positive offset is
requestedprotected int segmentNotFound(int offset, int start)
public int getLastValidOffset()
public final void changeSegmentLength(int startIndex, int change)
public final void shiftSegments(int startIndex, int shift)
public void removeAll()
public void remove(int startIndex, int endIndex)
protected int [] remove(int [] array, int startIndex, int endIndex)
protected void insert(SegmentArray segmentArray, int startIndex)
protected static int [] insert(int [] array, int [] insertArray, int startIndex, int insertLength, int mySegmentCount)
public int getSegmentStart(int index)
public int getSegmentEnd(int index)
public int getSegmentCount()