|
AlgART Home | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.algart.arrays.AbstractArray
net.algart.arrays.AbstractCharArray
net.algart.arrays.AbstractUpdatableCharArray
public abstract class AbstractUpdatableCharArray extends AbstractCharArray implements UpdatableCharArray
Implementation of almost all basic functions of UpdatableCharArray interface.
The only CharArray.getChar(long) and UpdatableCharArray.setChar(long, char) methods
are not defined in this class;
all other methods are implemented via calls of these 2 methods.
AlgART Laboratory 2007-2013
| Modifier and Type | Field and Description |
|---|
| Fields inherited from class net.algart.arrays.AbstractArray |
|---|
capacity, length, underlyingArrays |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractUpdatableCharArray(long initialCapacityAndLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
Equivalent to the constructor AbstractUpdatableCharArray(long, long, boolean, Array...),
where both initialCapacity and initialLength arguments are equal to
initialCapacityAndLength. |
protected |
AbstractUpdatableCharArray(long initialCapacity,
long initialLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
Creates an updatable array with the given initial capacity and length. |
| Modifier and Type | Method and Description |
|---|---|
UpdatableArray |
asCopyOnNextWrite()
This implementation returns updatableClone(Arrays.SMM). |
CharArray |
asImmutable()
This implementation returns an instance of the subclass of AbstractCharArray,
where the following method are overridden and call the same methods of this instance:
AbstractCharArray.getChar(long), AbstractCharArray.getData(long, Object, int, int),
AbstractCharArray.getData(long, Object),
AbstractCharArray.loadResources(ArrayContext, long, long),
AbstractCharArray.flushResources(ArrayContext, long, long, boolean) and
AbstractCharArray.freeResources(ArrayContext, long, long, boolean). |
UpdatableCharArray |
asUnresizable()
This implementation returns this object. |
UpdatableArray |
copy(Array src)
This implementation calls defaultCopy(thisInstance, src). |
void |
copy(long destIndex,
long srcIndex)
This implementation calls setChar(destIndex, getChar(srcIndex)). |
void |
copy(long destIndex,
long srcIndex,
long count)
This implementation is based on a loop of calls of copy(long, long) method. |
UpdatableCharArray |
fill(char value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableCharArray |
fill(double value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableCharArray |
fill(long value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableCharArray |
fill(long position,
long count,
char value)
This implementation does the following: subArr(position, count).copy(Arrays.nCharCopies(count, value)). |
UpdatableCharArray |
fill(long position,
long count,
double value)
This implementation just calls fill(position, count, (char)value). |
UpdatableCharArray |
fill(long position,
long count,
long value)
This implementation just calls fill(position, count, (char)value). |
boolean |
isImmutable()
This implementation returns false. |
abstract void |
setChar(long index,
char value)
Sets the element #index to specified value. |
UpdatableArray |
setData(long arrayPos,
java.lang.Object srcArray)
This implementation calls setData(long, Object, int, int)
with corresponding arguments. |
UpdatableArray |
setData(long arrayPos,
java.lang.Object srcArray,
int srcArrayOffset,
int count)
This implementation is based on a loop of calls of setChar(long, char) method. |
void |
setDouble(long index,
double value)
Sets the element #index by convertion from double, as (xxx)value for numeric element type xxx (byte, short, int, long, float, double or char), or as value!=0.0 for boolean element type. |
void |
setElement(long index,
java.lang.Object value)
This implementation calls setChar(index, (Character)value).charValue()). |
void |
setInt(long index,
int value)
Equivalent to setLong(index, (long)value),
but may work little faster. |
void |
setLong(long index,
long value)
Sets the element #index by convertion from long, as (xxx)value for numeric element type xxx (byte, short, int, long, float, double or char), or as value!=0 for boolean element type. |
void |
setNonNew()
This implementation calls setNewStatus(false). |
UpdatableArray |
shallowClone()
This implementation returns (UpdatableArray)super. shallowClone(). |
UpdatableCharArray |
subArr(long position,
long count)
This implementation returns subArray(position, position + count). |
UpdatableCharArray |
subArray(long fromIndex,
long toIndex)
This implementation returns new instance of AbstractUpdatableCharArray with the same memory model
and underlying arrays, that were passed to the constructor of this instance,
and with overridden methods AbstractCharArray.getChar(long), setChar(long, char),
AbstractCharArray.getData(long, Object, int, int) and
setData(long, Object, int, int)
calling the same methods of this instance with corresponding corrections of the arguments. |
void |
swap(long firstIndex,
long secondIndex)
This implementation swaps two elements by AbstractCharArray.getChar(long)
and setChar(long, char) methods. |
void |
swap(long firstIndex,
long secondIndex,
long count)
This implementation is based on a loop of calls of swap(long, long) method. |
UpdatableArray |
swap(UpdatableArray another)
This implementation calls defaultSwap(thisInstance, another). |
java.lang.String |
toString()
Returns a brief string description of this object. |
| Methods inherited from class net.algart.arrays.AbstractCharArray |
|---|
asTrustedImmutable, bitsPerElement, buffer, buffer, buffer, buffer, checkUnallowedMutation, elementType, flushResources, flushResources, freeResources, freeResources, getChar, getData, getData, getDouble, getElement, getInt, getLong, indexOf, indexOf, indexOf, isCopyOnNextWrite, isUnresizable, lastIndexOf, lastIndexOf, lastIndexOf, loadResources, loadResources, maxPossibleValue, maxPossibleValue, minPossibleValue, minPossibleValue, mutableClone, mutableType, type, updatableClone, updatableType |
| Methods inherited from class net.algart.arrays.AbstractArray |
|---|
byteOrder, capacity, checkCopyArguments, checkSubArrArguments, checkSubArrayArguments, checkSwapArguments, defaultAppend, defaultBuffer, defaultBufferCapacity, defaultCopy, defaultCopy, defaultSwap, equals, equals, flushResources, freeResources, hashCode, hashCode, isLazy, isNew, isNewReadOnlyView, isZeroFilled, length, newJavaArray, setNewReadOnlyViewStatus, setNewStatus, standardObjectClone |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.algart.arrays.CharArray |
|---|
asTrustedImmutable, buffer, buffer, buffer, buffer, getChar, indexOf, lastIndexOf, mutableClone, mutableType, type, updatableClone, updatableType |
| Methods inherited from interface net.algart.arrays.PFixedArray |
|---|
getInt, getLong, indexOf, lastIndexOf, maxPossibleValue, minPossibleValue |
| Methods inherited from interface net.algart.arrays.PArray |
|---|
bitsPerElement, getDouble, indexOf, isZeroFilled, lastIndexOf, maxPossibleValue, minPossibleValue |
| Methods inherited from interface net.algart.arrays.Array |
|---|
byteOrder, capacity, checkUnallowedMutation, elementType, equals, flushResources, flushResources, freeResources, freeResources, getData, getData, getElement, hashCode, isCopyOnNextWrite, isLazy, isNew, isNewReadOnlyView, isUnresizable, length, loadResources, newJavaArray |
| Constructor Detail |
|---|
protected AbstractUpdatableCharArray(long initialCapacity,
long initialLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
This array is not new by default.
This is correct usually, because this class is often used
for creating a view of another data. However, if the instance
if this class does not depend on any other data sources,
you may call setNewStatus(true) in
the constructor of your subclass.
initialCapacity - initial capacity of the array.initialLength - initial length of the array.underlyingArraysAreParallel - see the same argument of
AbstractCharArray.AbstractCharArray(long, long, boolean, Array...).underlyingArrays - see the same argument of
AbstractArray.AbstractArray(long, long, Array...).java.lang.NullPointerException - if underlyingArrays argument or some of underlyingArrays[k]
elements is null.java.lang.IllegalArgumentException - if the initialCapacity or initialLength arguments
are illegal (negative, or capacity < length).SizeMismatchException - if underlyingArraysAreParallel=true,
underlyingArrays.length>1 and some of passed arrays
have different lengths.
protected AbstractUpdatableCharArray(long initialCapacityAndLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
AbstractUpdatableCharArray(long, long, boolean, Array...),
where both initialCapacity and initialLength arguments are equal to
initialCapacityAndLength.
initialCapacityAndLength - initial capacity and length of the array.underlyingArraysAreParallel - see AbstractUpdatableCharArray(long, long, boolean, Array...).underlyingArrays - see AbstractUpdatableCharArray(long, long, boolean, Array...)java.lang.IllegalArgumentException - if the passed argument are illegal (negative).| Method Detail |
|---|
public UpdatableCharArray subArray(long fromIndex,
long toIndex)
AbstractUpdatableCharArray with the same memory model
and underlying arrays, that were passed to the constructor of this instance,
and with overridden methods AbstractCharArray.getChar(long), setChar(long, char),
AbstractCharArray.getData(long, Object, int, int) and
setData(long, Object, int, int)
calling the same methods of this instance with corresponding corrections of the arguments.
The returned instance also have overridden methods AbstractCharArray.loadResources(ArrayContext, long, long),
AbstractCharArray.flushResources(ArrayContext, long, long, boolean) and
AbstractCharArray.freeResources(ArrayContext, long, long, boolean),
that also call the same methods of this instance with corresponding correction of their fromIndex
argument.
The returned instance also have overridden method AbstractArray.isLazy(),
that just calls the same methods of this instance with the same arguments.
subArray in interface ArraysubArray in interface UpdatableArraysubArray in interface UpdatableCharArraysubArray in interface UpdatablePArraysubArray in interface UpdatablePFixedArraysubArray in class AbstractCharArrayfromIndex - low endpoint (inclusive) of the subarray.toIndex - high endpoint (exclusive) of the subarray.java.lang.IndexOutOfBoundsException - for illegal fromIndex and toIndex
(fromIndex < 0 || toIndex > length() || fromIndex > toIndex).Array.subArr(long, long)
public UpdatableCharArray subArr(long position,
long count)
AbstractArraysubArray(position, position + count).
Please note that the exception message can be not fully correct for the very exotic case
position+count>Long.MAX_VALUE.
subArr in interface ArraysubArr in interface UpdatableArraysubArr in interface UpdatableCharArraysubArr in interface UpdatablePArraysubArr in interface UpdatablePFixedArraysubArr in class AbstractArrayposition - start position (inclusive) of the subarray.count - number of elements in the subarray.Array.subArray(long, long)
public void setDouble(long index,
double value)
UpdatablePArray
setDouble in interface UpdatablePArrayindex - index of element to replace.value - element to be stored at the specified position.PArray.getDouble(long)
public void setLong(long index,
long value)
UpdatablePArray
setLong in interface UpdatablePArrayindex - index of element to replace.value - element to be stored at the specified position.PFixedArray.getLong(long)
public void setInt(long index,
int value)
UpdatablePArraysetLong(index, (long)value),
but may work little faster.
setInt in interface UpdatablePArrayindex - index of element to replace.value - element to be stored at the specified position.PFixedArray.getInt(long)
public abstract void setChar(long index,
char value)
UpdatableCharArray
setChar in interface UpdatableCharArrayindex - index of element to replace.value - element to be stored at the specified position.public final UpdatableCharArray fill(double value)
fill(0, thisArray.length(), value).
fill in interface UpdatablePArrayvalue - the value to be stored in all elements of the array.UpdatablePArray.fill(long, long, double),
Arrays.zeroFill(UpdatableArray)
public UpdatableCharArray fill(long position,
long count,
double value)
fill(position, count, (char)value).
fill in interface UpdatablePArrayposition - start index (inclusive) to be filled.count - number of filled elements.value - the value to be stored in the elements of the array.java.lang.IndexOutOfBoundsException - for illegal position and count
(position < 0 || count < 0 || position + count > length()).UpdatablePArray.fill(double),
Arrays.zeroFill(UpdatableArray)public final UpdatableCharArray fill(long value)
fill(0, thisArray.length(), value).
fill in interface UpdatablePArrayvalue - the value to be stored in all elements of the array.UpdatablePArray.fill(long, long, long),
Arrays.zeroFill(UpdatableArray)
public UpdatableCharArray fill(long position,
long count,
long value)
fill(position, count, (char)value).
fill in interface UpdatablePArrayposition - start index (inclusive) to be filled.count - number of filled elements.value - the value to be stored in the elements of the array.java.lang.IndexOutOfBoundsException - for illegal position and count
(position < 0 || count < 0 || position + count > length()).UpdatablePArray.fill(long),
Arrays.zeroFill(UpdatableArray)public final UpdatableCharArray fill(char value)
fill(0, thisArray.length(), value).
fill in interface UpdatableCharArrayvalue - the value to be stored in all elements of the array.UpdatableCharArray.fill(long, long, char),
Arrays.zeroFill(UpdatableArray)
public UpdatableCharArray fill(long position,
long count,
char value)
subArr(position, count).copy(Arrays.nCharCopies(count, value)).
Please override this method if it's possible to perform the same task more efficiently.
fill in interface UpdatableCharArrayposition - start index (inclusive) to be filled.count - number of filled elements.value - the value to be stored in the elements of the array.java.lang.IndexOutOfBoundsException - for illegal position and count
(position < 0 || count < 0 || position + count > length()).UpdatableCharArray.fill(char),
Arrays.zeroFill(UpdatableArray)public boolean isImmutable()
isImmutable in interface ArrayisImmutable in class AbstractCharArrayArray.asImmutable()public CharArray asImmutable()
AbstractCharArray,
where the following method are overridden and call the same methods of this instance:
AbstractCharArray.getChar(long), AbstractCharArray.getData(long, Object, int, int),
AbstractCharArray.getData(long, Object),
AbstractCharArray.loadResources(ArrayContext, long, long),
AbstractCharArray.flushResources(ArrayContext, long, long, boolean) and
AbstractCharArray.freeResources(ArrayContext, long, long, boolean).
The returned instance also have overridden method AbstractArray.isLazy(),
that just calls the same methods of this instance with the same arguments.
asImmutable in interface ArrayasImmutable in interface CharArrayasImmutable in interface PArrayasImmutable in interface PFixedArrayasImmutable in class AbstractCharArrayArray.isImmutable(),
Array.asTrustedImmutable(),
Array.mutableClone(MemoryModel),
Array.updatableClone(MemoryModel),
UpdatableArray.asUnresizable()public UpdatableArray shallowClone()
shallowClone().
shallowClone in interface ArrayshallowClone in interface UpdatableArrayshallowClone in class AbstractArrayArray.length(),
Array.capacity(),
DirectAccessible.javaArrayOffset(),
Array.isCopyOnNextWrite()
public void setElement(long index,
java.lang.Object value)
setElement in interface UpdatableArrayindex - index of element to replace.value - element to be stored at the specified position.java.lang.IndexOutOfBoundsException - if index is out of range 0..length()-1.java.lang.NullPointerException - if value == null and it is an array of primitive elementsjava.lang.ClassCastException - if it is an array of primitive elements and value
is not a corresponding wrapped class
(Boolean, Integer, etc.)java.lang.ArrayStoreException - if it is an array of non-primitive elements and value
is not an instance of AbstractCharArray.elementType() class
public UpdatableArray setData(long arrayPos,
java.lang.Object srcArray,
int srcArrayOffset,
int count)
setChar(long, char) method.
Please override this method if it's possible to perform the same task more efficiently
than such a loop.
setData in interface UpdatableArrayarrayPos - starting position in this AlgART array.srcArray - the source Java array.srcArrayOffset - starting position in the source Java array.count - the number of elements to be copied.java.lang.NullPointerException - if srcArray argument is null.java.lang.IllegalArgumentException - if srcArray argument is not an array.java.lang.IndexOutOfBoundsException - if copying would cause access of data outside this array or source Java array.java.lang.ArrayStoreException - if destArray element type mismatches with this array
elementType().java.lang.ClassCastException - if destArray element type mismatches with this array
elementType()
(both this and ArrayStoreException are possible,
depending on implementation).DirectAccessible,
Array.getData(long, Object, int, int)
public UpdatableArray setData(long arrayPos,
java.lang.Object srcArray)
setData(long, Object, int, int)
with corresponding arguments.
setData in interface UpdatableArrayarrayPos - starting position in this AlgART array.srcArray - the source Java array.java.lang.NullPointerException - if srcArray argument is null.java.lang.IllegalArgumentException - if srcArray argument is not an array.java.lang.IndexOutOfBoundsException - if copying would cause access of data outside this array or source Java array.java.lang.ArrayStoreException - if destArray element type mismatches with this array
AbstractCharArray.elementType().java.lang.ClassCastException - if destArray element type mismatches with this array
AbstractCharArray.elementType()
(both this and ArrayStoreException are possible,
depending on implementation).DirectAccessible,
UpdatableArray.setData(long, Object, int, int),
Array.getData(long, Object),
UpdatableBitArray.setBits(long, long[], long, long)
public void copy(long destIndex,
long srcIndex)
copy in interface UpdatableArraydestIndex - index of element to replace.srcIndex - index of element to be copied.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.
public void copy(long destIndex,
long srcIndex,
long count)
copy(long, long) method.
copy in interface UpdatableArraydestIndex - starting index of element to replace.srcIndex - starting index of element to be copied.count - the number of elements to be copied.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.
public void swap(long firstIndex,
long secondIndex)
AbstractCharArray.getChar(long)
and setChar(long, char) methods.
swap in interface ArrayExchangerswap in interface UpdatableArrayfirstIndex - first index of element to exchange.secondIndex - second index of element to exchange.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.
public void swap(long firstIndex,
long secondIndex,
long count)
swap(long, long) method.
swap in interface UpdatableArrayfirstIndex - starting first index of element to exchange.secondIndex - starting second index of element to exchange.count - the number of elements to be exchanged.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.public UpdatableArray copy(Array src)
defaultCopy(thisInstance, src).
copy in interface UpdatableArraysrc - the source array.java.lang.NullPointerException - if src argument is null.java.lang.IllegalArgumentException - if the source and this element types do not match.Arrays.copy(ArrayContext, UpdatableArray, Array)public UpdatableArray swap(UpdatableArray another)
defaultSwap(thisInstance, another).
swap in interface UpdatableArrayanother - another array.java.lang.NullPointerException - if another argument is null.java.lang.IllegalArgumentException - if another and this element types do not match.public void setNonNew()
setNewStatus(false).
setNonNew in interface UpdatableArraypublic UpdatableArray asCopyOnNextWrite()
updatableClone(Arrays.SMM).
asCopyOnNextWrite in interface ArrayasCopyOnNextWrite in interface UpdatableArrayasCopyOnNextWrite in class AbstractCharArrayArray.isCopyOnNextWrite(),
MemoryModel.newLazyCopy(Array),
MemoryModel.newUnresizableLazyCopy(Array)public UpdatableCharArray asUnresizable()
asUnresizable in interface UpdatableArrayasUnresizable in interface UpdatableCharArrayasUnresizable in interface UpdatablePArrayasUnresizable in interface UpdatablePFixedArrayArray.isUnresizable()public java.lang.String toString()
ArrayThe result of this method may depend on implementation and usually contains a short description of the array length, capacity, element type.
Note: for character arrays, unlike CharSequence.toString(),
this method works as for all other array types.
If you need to convert a character array to a string,
containing all characters of the array, you may use
Arrays.toString(CharArray) method.
toString in interface ArraytoString in class AbstractCharArray
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||