|
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.AbstractIntArray
net.algart.arrays.AbstractUpdatableIntArray
public abstract class AbstractUpdatableIntArray extends AbstractIntArray implements UpdatableIntArray
Implementation of almost all basic functions of UpdatableIntArray interface.
The only IntArray.getInt(long) and UpdatableIntArray.setInt(long, int) 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 |
AbstractUpdatableIntArray(long initialCapacityAndLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
Equivalent to the constructor AbstractUpdatableIntArray(long, long, boolean, Array...),
where both initialCapacity and initialLength arguments are equal to
initialCapacityAndLength. |
protected |
AbstractUpdatableIntArray(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). |
IntArray |
asImmutable()
This implementation returns an instance of the subclass of AbstractIntArray,
where the following method are overridden and call the same methods of this instance:
AbstractIntArray.getInt(long), AbstractIntArray.getData(long, Object, int, int),
AbstractIntArray.getData(long, Object),
AbstractIntArray.loadResources(ArrayContext, long, long),
AbstractIntArray.flushResources(ArrayContext, long, long, boolean) and
AbstractIntArray.freeResources(ArrayContext, long, long, boolean). |
UpdatableIntArray |
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 setInt(destIndex, getInt(srcIndex)). |
void |
copy(long destIndex,
long srcIndex,
long count)
This implementation is based on a loop of calls of copy(long, long) method. |
UpdatableIntArray |
fill(double value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableIntArray |
fill(int value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableIntArray |
fill(long value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableIntArray |
fill(long position,
long count,
double value)
This implementation just calls fill(position, count, (int)value). |
UpdatableIntArray |
fill(long position,
long count,
int value)
This implementation does the following: subArr(position, count).copy(Arrays.nIntCopies(count, value)). |
UpdatableIntArray |
fill(long position,
long count,
long value)
This implementation just calls fill(position, count, (int)value). |
boolean |
isImmutable()
This implementation returns false. |
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 setInt(long, int) 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 setInt(index, (Integer)value).intValue()). |
abstract void |
setInt(long index,
int value)
Sets the element #index to specified value. |
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(). |
UpdatableIntArray |
subArr(long position,
long count)
This implementation returns subArray(position, position + count). |
UpdatableIntArray |
subArray(long fromIndex,
long toIndex)
This implementation returns new instance of AbstractUpdatableIntArray with the same memory model
and underlying arrays, that were passed to the constructor of this instance,
and with overridden methods AbstractIntArray.getInt(long), setInt(long, int),
AbstractIntArray.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 AbstractIntArray.getInt(long)
and setInt(long, int) 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.AbstractIntArray |
|---|
asTrustedImmutable, bitsPerElement, buffer, buffer, buffer, buffer, checkUnallowedMutation, elementType, flushResources, flushResources, freeResources, freeResources, 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.IntArray |
|---|
asTrustedImmutable, buffer, buffer, buffer, buffer, getInt, indexOf, lastIndexOf, mutableClone, mutableType, type, updatableClone, updatableType |
| Methods inherited from interface net.algart.arrays.PFixedArray |
|---|
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 AbstractUpdatableIntArray(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
AbstractIntArray.AbstractIntArray(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 AbstractUpdatableIntArray(long initialCapacityAndLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
AbstractUpdatableIntArray(long, long, boolean, Array...),
where both initialCapacity and initialLength arguments are equal to
initialCapacityAndLength.
initialCapacityAndLength - initial capacity and length of the array.underlyingArraysAreParallel - see AbstractUpdatableIntArray(long, long, boolean, Array...).underlyingArrays - see AbstractUpdatableIntArray(long, long, boolean, Array...)java.lang.IllegalArgumentException - if the passed argument are illegal (negative).| Method Detail |
|---|
public UpdatableIntArray subArray(long fromIndex,
long toIndex)
AbstractUpdatableIntArray with the same memory model
and underlying arrays, that were passed to the constructor of this instance,
and with overridden methods AbstractIntArray.getInt(long), setInt(long, int),
AbstractIntArray.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 AbstractIntArray.loadResources(ArrayContext, long, long),
AbstractIntArray.flushResources(ArrayContext, long, long, boolean) and
AbstractIntArray.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 UpdatableIntArraysubArray in interface UpdatablePArraysubArray in interface UpdatablePFixedArraysubArray in interface UpdatablePIntegerArraysubArray in class AbstractIntArrayfromIndex - 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 UpdatableIntArray 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 UpdatableIntArraysubArr in interface UpdatablePArraysubArr in interface UpdatablePFixedArraysubArr in interface UpdatablePIntegerArraysubArr 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 abstract void setInt(long index,
int value)
UpdatableIntArray
setInt in interface UpdatableIntArraysetInt in interface UpdatablePArrayindex - index of element to replace.value - element to be stored at the specified position.PFixedArray.getInt(long)public final UpdatableIntArray 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 UpdatableIntArray fill(long position,
long count,
double value)
fill(position, count, (int)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 UpdatableIntArray 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 UpdatableIntArray fill(long position,
long count,
long value)
fill(position, count, (int)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 UpdatableIntArray fill(int value)
fill(0, thisArray.length(), value).
fill in interface UpdatableIntArrayvalue - the value to be stored in all elements of the array.UpdatableIntArray.fill(long, long, int),
Arrays.zeroFill(UpdatableArray)
public UpdatableIntArray fill(long position,
long count,
int value)
subArr(position, count).copy(Arrays.nIntCopies(count, value)).
Please override this method if it's possible to perform the same task more efficiently.
fill in interface UpdatableIntArrayposition - 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()).UpdatableIntArray.fill(int),
Arrays.zeroFill(UpdatableArray)public boolean isImmutable()
isImmutable in interface ArrayisImmutable in class AbstractIntArrayArray.asImmutable()public IntArray asImmutable()
AbstractIntArray,
where the following method are overridden and call the same methods of this instance:
AbstractIntArray.getInt(long), AbstractIntArray.getData(long, Object, int, int),
AbstractIntArray.getData(long, Object),
AbstractIntArray.loadResources(ArrayContext, long, long),
AbstractIntArray.flushResources(ArrayContext, long, long, boolean) and
AbstractIntArray.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 IntArrayasImmutable in interface PArrayasImmutable in interface PFixedArrayasImmutable in interface PIntegerArrayasImmutable in class AbstractIntArrayArray.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 AbstractIntArray.elementType() class
public UpdatableArray setData(long arrayPos,
java.lang.Object srcArray,
int srcArrayOffset,
int count)
setInt(long, int) 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
AbstractIntArray.elementType().java.lang.ClassCastException - if destArray element type mismatches with this array
AbstractIntArray.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)
AbstractIntArray.getInt(long)
and setInt(long, int) 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 AbstractIntArrayArray.isCopyOnNextWrite(),
MemoryModel.newLazyCopy(Array),
MemoryModel.newUnresizableLazyCopy(Array)public UpdatableIntArray asUnresizable()
asUnresizable in interface UpdatableArrayasUnresizable in interface UpdatableIntArrayasUnresizable in interface UpdatablePArrayasUnresizable in interface UpdatablePFixedArrayasUnresizable in interface UpdatablePIntegerArrayArray.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 AbstractIntArray
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||