public class RunArray
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
RunArray class implements a space-efficient growable
array that tends to be constant over long runs of the possible indices.| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected int |
cacheRunIndex
The cache index of
runs. |
protected int |
cacheRunStart
The cache index of the
RunArray
(Sum of run lengths up to cacheRunIndex). |
protected int |
count
The number of valid components in the array (Sum of run lengths).
|
protected VArray |
runs
The buffer of the run length.
|
protected VArray |
values
The value buffer into which the components of the array
are stored.
|
| 修飾子 | コンストラクタと説明 |
|---|---|
|
RunArray()
Constructs an empty array.
|
|
RunArray(java.lang.Class componentType)
Constructs an empty array with the specified component type.
|
|
RunArray(int size,
java.lang.Object value)
Constructs an array with the specified size (length), whose
every component equals to the specified value.
|
|
RunArray(int size,
java.lang.Object value,
java.lang.Class componentType)
Constructs an array with the specified size (length), whose
every component equals to the specified value.
|
protected |
RunArray(VArray runs,
VArray values,
int count)
Constructs an array with the specified runs, values, and count.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
RunArray |
append(int length,
java.lang.Object defObj)
Grows the length of this array to the current array's length
plus the specified
length. |
RunArray |
append(java.lang.Object obj)
Appends the object to this array.
|
RunArray |
append(RunArray array)
Appends the components of the
RunArray object to
this array. |
java.lang.Object |
clone()
Returns a clone of this array.
|
protected void |
copyFrom(RunArray array)
Copies into the contents of this array from the specified array.
|
java.util.Enumeration |
elements()
Returns an enumeration of the components of this array.
|
java.util.Enumeration |
elements(int begin,
int end)
Returns an enumeration of the components of this array.
|
boolean |
equals(java.lang.Object anObject)
Compares two Objects for equality.
|
java.lang.Object |
get(int index)
Returns the component object at the specified index.
|
java.lang.Class |
getComponentType()
Returns the component type of this array.
|
protected int[] |
getRunAndOffset(int index)
Returns the run length and the run offset at the specified index.
|
int |
getRunLengthAt(int index)
Returns the run length (the number of the constant occurrence)
at the specified index.
|
int |
getRunOffsetAt(int index)
Returns the run offset (the starting index of the constant
occurrence) at the specified index.
|
int |
getValueCount()
Returns the number of the components in this array.
|
java.lang.Object[] |
getValues()
Returns the components in this array.
|
java.lang.Object[] |
getValues(int begin,
int end)
Returns the components in this array.
|
int |
hashCode()
Returns a hashcode for this array.
|
RunArray |
insert(int offset,
RunArray array)
Inserts the components of the
RunArray object to
this array from the specified offset. |
boolean |
isEmpty()
Tests if this array has no components.
|
int |
length()
Returns the length of this array, i.e., the number of components
in this array.
|
void |
remove(int offset,
int size)
Removes the components in this array from the specified
offset. |
void |
removeAll()
Removes all components from this array and sets its length to zero.
|
protected void |
replace(int bRun,
int bOffset,
int eRun,
int eOffset,
VArray rRuns,
VArray rValues)
Replaces the components of this array with the runs and values.
|
RunArray |
replace(int begin,
int end,
RunArray array)
Replaces the components of this array with the components of the
RunArray object. |
int |
size()
Returns the size of this array, i.e., the number of components
in this array.
|
RunArray |
subarray(int beginIndex)
Returns a new array that is a subarray of this array.
|
RunArray |
subarray(int beginIndex,
int endIndex)
Returns a new array that is a subarray of this array.
|
java.lang.String |
toString()
Returns a string representation of this array.
|
protected VArray runs
values) is constant.protected VArray values
protected int count
protected int cacheRunIndex
runs.protected int cacheRunStart
RunArray
(Sum of run lengths up to cacheRunIndex).public RunArray()
public RunArray(java.lang.Class componentType)
componentType - the component type of the array.java.lang.IllegalArgumentException - if the specified component type
is a primitive type.public RunArray(int size,
java.lang.Object value)
size - the size (length) of the array.value - the components of the array.public RunArray(int size,
java.lang.Object value,
java.lang.Class componentType)
size - the size (length) of the array.value - the components of the array.componentType - the component type of the array.java.lang.IllegalArgumentException - if the specified component type
is a primitive type.public final int size()
public final int length()
public final boolean isEmpty()
true if this array has no components;
false otherwise.public final java.util.Enumeration elements()
public final java.util.Enumeration elements(int begin,
int end)
begin - the beginning index to get components, inclusive.end - the ending index to get components, exclusive.java.lang.ArrayIndexOutOfBoundsException - if the begin, or
the end is out of range.public final java.lang.Class getComponentType()
public final int getValueCount()
public final java.lang.Object[] getValues()
public final java.lang.Object[] getValues(int begin,
int end)
begin - the beginning index to get components, inclusive.end - the ending index to get components, exclusive.java.lang.ArrayIndexOutOfBoundsException - if the begin, or
the end is out of range.public final java.lang.Object get(int index)
index - an index into this array.java.lang.ArrayIndexOutOfBoundsException - if an invalid index was
given.public final int getRunLengthAt(int index)
index - an index into this array.java.lang.ArrayIndexOutOfBoundsException - if an invalid index was
given.public final int getRunOffsetAt(int index)
index - an index into this array.java.lang.ArrayIndexOutOfBoundsException - if an invalid index was
given.public int hashCode()
hashCode クラス内 java.lang.Objectpublic boolean equals(java.lang.Object anObject)
equals クラス内 java.lang.ObjectanObject - the reference object with which to compare.true if this array is the same as the anObject
argument; false otherwise.public final void removeAll()
public final void remove(int offset,
int size)
offset. The number of the components to be removed is
specified by the size. Each component in this array
with an index greater or equal to offset+size is
shifted downward.offset - the start index of the components to be removed.size - the number of the components to be removed.java.lang.ArrayIndexOutOfBoundsException - if the offset
or the size were invalid.public final RunArray subarray(int beginIndex)
beginIndex - the beginning index, inclusive.java.lang.ArrayIndexOutOfBoundsException - if the
beginIndex is out of range.public final RunArray subarray(int beginIndex, int endIndex)
beginIndex and extends to the
component at index endIndex-1.beginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.java.lang.ArrayIndexOutOfBoundsException - if the
beginIndex or the endIndex is
out of range.public final RunArray append(RunArray array)
RunArray object to
this array.array - an RunArray object.public final RunArray append(java.lang.Object obj)
obj - an object.public final RunArray append(int length, java.lang.Object defObj)
length. If this array isn't empty,
the last value is added to the end of the array. Otherwise,
defObj is added to the end of the array.length - object.defObj - an object.public final RunArray insert(int offset, RunArray array)
RunArray object to
this array from the specified offset.offset - the start index of the components to be inserted.array - a RunArray object.java.lang.ArrayIndexOutOfBoundsException - if the offset
was invalid.public final RunArray replace(int begin, int end, RunArray array)
RunArray object.begin - the beginning index to replace, inclusive.end - the ending index to replace, exclusive.array - a replacement RunArray object.java.lang.ArrayIndexOutOfBoundsException - if the begin
or the end is out of range.public java.lang.String toString()
toString クラス内 java.lang.Objectpublic java.lang.Object clone()
clone クラス内 java.lang.Objectprotected final int[] getRunAndOffset(int index)
protected final void replace(int bRun,
int bOffset,
int eRun,
int eOffset,
VArray rRuns,
VArray rValues)
bRun - the beginning index of runs, inclusive.bOffset - the beginning offset of runs.eRun - the ending index of runs, inclusive.eOffset - the ending offset of runs.rRuns - a run length array.rValues - a value array.protected final void copyFrom(RunArray array)