All Packages Class Hierarchy This Package Previous Next Index
Class jp.kyasu.util.RunArray
java.lang.Object
|
+----jp.kyasu.util.RunArray
- public class RunArray
- extends Object
- implements Cloneable, Serializable
The RunArray
class implements a space-efficient growable
array that tends to be constant over long runs of the possible indices.
- Version:
- 17 Jun 1998
- Author:
- Kazuki YASUMATSU
-
RunArray()
- Constructs an empty array.
-
RunArray(Class)
- Constructs an empty array with the specified component type.
-
RunArray(int, Object)
- Constructs an array with the specified size (length), whose
every component equals to the specified value.
-
RunArray(int, Object, Class)
- Constructs an array with the specified size (length), whose
every component equals to the specified value.
-
append(int, Object)
- Grows the length of this array to the current array's length
plus the specified
length
.
-
append(Object)
- Appends the object to this array.
-
append(RunArray)
- Appends the components of the
RunArray
object to
this array.
-
clone()
- Returns a clone of this array.
-
elements()
- Returns an enumeration of the components of this array.
-
elements(int, int)
- Returns an enumeration of the components of this array.
-
equals(Object)
- Compares two Objects for equality.
-
get(int)
- Returns the component object at the specified index.
-
getComponentType()
- Returns the component type of this array.
-
getRunLengthAt(int)
- Returns the run length (the number of the constant occurrence)
at the specified index.
-
getRunOffsetAt(int)
- Returns the run offset (the starting index of the constant
occurrence) at the specified index.
-
getValueCount()
- Returns the number of the components in this array.
-
getValues()
- Returns the components in this array.
-
getValues(int, int)
- Returns the components in this array.
-
hashCode()
- Returns a hashcode for this array.
-
insert(int, RunArray)
- Inserts the components of the
RunArray
object to
this array from the specified offset
.
-
isEmpty()
- Tests if this array has no components.
-
length()
- Returns the length of this array, i.e., the number of components
in this array.
-
remove(int, int)
- Removes the components in this array from the specified
offset
.
-
removeAll()
- Removes all components from this array and sets its length to zero.
-
replace(int, int, RunArray)
- Replaces the components of this array with the components of the
RunArray
object.
-
size()
- Returns the size of this array, i.e., the number of components
in this array.
-
subarray(int)
- Returns a new array that is a subarray of this array.
-
subarray(int, int)
- Returns a new array that is a subarray of this array.
-
toString()
- Returns a string representation of this array.
RunArray
public RunArray()
- Constructs an empty array.
RunArray
public RunArray(Class componentType)
- Constructs an empty array with the specified component type.
- Parameters:
- componentType - the component type of the array.
- Throws: IllegalArgumentException
- if the specified component type
is a primitive type.
RunArray
public RunArray(int size,
Object value)
- Constructs an array with the specified size (length), whose
every component equals to the specified value.
- Parameters:
- size - the size (length) of the array.
- value - the components of the array.
RunArray
public RunArray(int size,
Object value,
Class componentType)
- Constructs an array with the specified size (length), whose
every component equals to the specified value.
- Parameters:
- size - the size (length) of the array.
- value - the components of the array.
- componentType - the component type of the array.
- Throws: IllegalArgumentException
- if the specified component type
is a primitive type.
size
public final int size()
- Returns the size of this array, i.e., the number of components
in this array.
- Returns:
- the size of this array.
length
public final int length()
- Returns the length of this array, i.e., the number of components
in this array.
- Returns:
- the length of this array.
isEmpty
public final boolean isEmpty()
- Tests if this array has no components.
- Returns:
-
true
if this array has no components;
false
otherwise.
elements
public final Enumeration elements()
- Returns an enumeration of the components of this array.
- Returns:
- an enumeration of the components of this array.
elements
public final Enumeration elements(int begin,
int end)
- Returns an enumeration of the components of this array.
- Parameters:
- begin - the beginning index to get components, inclusive.
- end - the ending index to get components, exclusive.
- Returns:
- an enumeration of the components of this array.
- Throws: ArrayIndexOutOfBoundsException
- if the
begin
, or
the end
is out of range.
getComponentType
public final Class getComponentType()
- Returns the component type of this array.
- Returns:
- the component type of this array.
getValueCount
public final int getValueCount()
- Returns the number of the components in this array.
- Returns:
- the number of the components in this array.
getValues
public final Object[] getValues()
- Returns the components in this array.
- Returns:
- the components in this array.
getValues
public final Object[] getValues(int begin,
int end)
- Returns the components in this array.
- Parameters:
- begin - the beginning index to get components, inclusive.
- end - the ending index to get components, exclusive.
- Returns:
- the components in this array.
- Throws: ArrayIndexOutOfBoundsException
- if the
begin
, or
the end
is out of range.
get
public final Object get(int index)
- Returns the component object at the specified index.
- Parameters:
- index - an index into this array.
- Returns:
- the component at the specified index.
- Throws: ArrayIndexOutOfBoundsException
- if an invalid index was
given.
getRunLengthAt
public final int getRunLengthAt(int index)
- Returns the run length (the number of the constant occurrence)
at the specified index.
- Parameters:
- index - an index into this array.
- Returns:
- the run length from the specified index.
- Throws: ArrayIndexOutOfBoundsException
- if an invalid index was
given.
getRunOffsetAt
public final int getRunOffsetAt(int index)
- Returns the run offset (the starting index of the constant
occurrence) at the specified index.
- Parameters:
- index - an index into this array.
- Returns:
- the run offset from the specified index.
- Throws: ArrayIndexOutOfBoundsException
- if an invalid index was
given.
hashCode
public int hashCode()
- Returns a hashcode for this array.
- Returns:
- a hash code value for this array.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object anObject)
- Compares two Objects for equality.
- Parameters:
- anObject - the reference object with which to compare.
- Returns:
-
true
if this array is the same as the anObject
argument; false
otherwise.
- Overrides:
- equals in class Object
removeAll
public final void removeAll()
- Removes all components from this array and sets its length to zero.
remove
public final void remove(int offset,
int size)
- Removes the components in this array from the specified
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.
- Parameters:
- offset - the start index of the components to be removed.
- size - the number of the components to be removed.
- Throws: ArrayIndexOutOfBoundsException
- if the
offset
or the size
were invalid.
subarray
public final RunArray subarray(int beginIndex)
- Returns a new array that is a subarray of this array. The subarray
begins at the specified index and extends to the end of this array.
- Parameters:
- beginIndex - the beginning index, inclusive.
- Returns:
- the subarray.
- Throws: ArrayIndexOutOfBoundsException
- if the
beginIndex
is out of range.
subarray
public final RunArray subarray(int beginIndex,
int endIndex)
- Returns a new array that is a subarray of this array. The subarray
begins at the specified
beginIndex
and extends to the
component at index endIndex-1
.
- Parameters:
- beginIndex - the beginning index, inclusive.
- endIndex - the ending index, exclusive.
- Returns:
- the subarray.
- Throws: ArrayIndexOutOfBoundsException
- if the
beginIndex
or the endIndex
is
out of range.
append
public final RunArray append(RunArray array)
- Appends the components of the
RunArray
object to
this array.
- Parameters:
- array - an
RunArray
object.
- Returns:
- this array.
append
public final RunArray append(Object obj)
- Appends the object to this array.
- Parameters:
- obj - an object.
- Returns:
- this array.
append
public final RunArray append(int length,
Object defObj)
- Grows the length of this array to the current array's length
plus the specified
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.
- Parameters:
- length - object.
- defObj - an object.
- Returns:
- this array.
insert
public final RunArray insert(int offset,
RunArray array)
- Inserts the components of the
RunArray
object to
this array from the specified offset
.
- Parameters:
- offset - the start index of the components to be inserted.
- array - a
RunArray
object.
- Returns:
- this array.
- Throws: ArrayIndexOutOfBoundsException
- if the
offset
was invalid.
replace
public final RunArray replace(int begin,
int end,
RunArray array)
- Replaces the components of this array with the components of the
RunArray
object.
- Parameters:
- begin - the beginning index to replace, inclusive.
- end - the ending index to replace, exclusive.
- array - a replacement
RunArray
object.
- Returns:
- this array.
- Throws: ArrayIndexOutOfBoundsException
- if the
begin
or the end
is out of range.
toString
public String toString()
- Returns a string representation of this array.
- Returns:
- a string representation of this array.
- Overrides:
- toString in class Object
clone
public Object clone()
- Returns a clone of this array.
- Returns:
- a clone of this array.
- Overrides:
- clone in class Object
All Packages Class Hierarchy This Package Previous Next Index