|
AlgART Home | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface UpdatablePArray extends PArray, UpdatableArray
AlgART array of primitive elements (boolean, char, byte, short, int, long, float or double), read/write access, no resizing.
Any class implementing this interface must implement one of
UpdatableBitArray, UpdatableCharArray,
UpdatableByteArray, UpdatableShortArray,
UpdatableIntArray, UpdatableLongArray,
UpdatableFloatArray, UpdatableDoubleArray
subinterfaces.
AlgART Laboratory 2007-2013
| Modifier and Type | Method and Description |
|---|---|
UpdatablePArray |
asUnresizable()
Returns an unresizable view of this array. |
UpdatablePArray |
fill(double value)
Fills all elements of this array by the specified value. |
UpdatablePArray |
fill(long value)
Fills all elements of this array by the specified value. |
UpdatablePArray |
fill(long position,
long count,
double value)
Fills count elements of this array, starting from position index, by the specified value. |
UpdatablePArray |
fill(long position,
long count,
long value)
Fills count elements of this array, starting from position index, by the specified value. |
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 |
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. |
UpdatablePArray |
subArr(long position,
long count)
Equivalent to subArray(position, position + count). |
UpdatablePArray |
subArray(long fromIndex,
long toIndex)
Returns a view of the portion of this array between fromIndex, inclusive, and toIndex, exclusive. |
java.lang.Class<? extends UpdatablePArray> |
updatableType()
Returns the canonical updatable AlgART type of arrays with the same element types: the class of one of 9 basic interfaces, describing all kinds of updatable AlgART arrays for 8 primitive and any non-primitive element types. |
| Methods inherited from interface net.algart.arrays.PArray |
|---|
asImmutable, asTrustedImmutable, bitsPerElement, getDouble, indexOf, isZeroFilled, lastIndexOf, maxPossibleValue, minPossibleValue, mutableClone, mutableType, type, updatableClone |
| Methods inherited from interface net.algart.arrays.UpdatableArray |
|---|
asCopyOnNextWrite, copy, copy, copy, setData, setData, setElement, setNonNew, shallowClone, swap, swap, swap |
| Methods inherited from interface net.algart.arrays.Array |
|---|
buffer, buffer, buffer, buffer, byteOrder, capacity, checkUnallowedMutation, elementType, equals, flushResources, flushResources, freeResources, freeResources, getData, getData, getElement, hashCode, isCopyOnNextWrite, isImmutable, isLazy, isNew, isNewReadOnlyView, isUnresizable, length, loadResources, newJavaArray, toString |
| Method Detail |
|---|
void setDouble(long index,
double value)
index - index of element to replace.value - element to be stored at the specified position.java.lang.IndexOutOfBoundsException - if index out of range 0..length()-1.PArray.getDouble(long)
void setLong(long index,
long value)
index - index of element to replace.value - element to be stored at the specified position.java.lang.IndexOutOfBoundsException - if index out of range 0..length()-1.PFixedArray.getLong(long)
void setInt(long index,
int value)
setLong(index, (long)value),
but may work little faster.
index - index of element to replace.value - element to be stored at the specified position.java.lang.IndexOutOfBoundsException - if index out of range 0..length()-1.PFixedArray.getInt(long)UpdatablePArray fill(double value)
fill(0, thisArray.length(), value).
value - the value to be stored in all elements of the array.fill(long, long, double),
Arrays.zeroFill(UpdatableArray)
UpdatablePArray fill(long position,
long count,
double value)
for (long k = 0; k < count; k++) {
setDouble(position + k, value);
}
but works much faster and checks indexes
(and throws possible IndexOutOfBoundsException) in the very beginning.
position - 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()).fill(double),
Arrays.zeroFill(UpdatableArray)UpdatablePArray fill(long value)
fill(0, thisArray.length(), value).
value - the value to be stored in all elements of the array.fill(long, long, long),
Arrays.zeroFill(UpdatableArray)
UpdatablePArray fill(long position,
long count,
long value)
for (long k = 0; k < count; k++) {
setLong(position + k, value);
}
but works much faster and checks indexes
(and throws possible IndexOutOfBoundsException) in the very beginning.
position - 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()).fill(long),
Arrays.zeroFill(UpdatableArray)java.lang.Class<? extends UpdatablePArray> updatableType()
ArrayUpdatableBitArray.class, if this object is an instance of BitArray,UpdatableCharArray.class, if this object is an instance of CharArray,UpdatableByteArray.class, if this object is an instance of ByteArray,UpdatableShortArray.class, if this object is an instance of ShortArray,UpdatableIntArray.class, if this object is an instance of IntArray,UpdatableLongArray.class, if this object is an instance of LongArray,UpdatableFloatArray.class, if this object is an instance of FloatArray,UpdatableDoubleArray.class, if this object is an instance of DoubleArray,UpdatableObjectArray.class, if this object is an instance of ObjectArray.There is a guarantee that this method works very quickly (usually it just returns a constant value).
updatableType in interface ArrayupdatableType in interface PArray
UpdatablePArray subArray(long fromIndex,
long toIndex)
ArrayArray.capacity() method) will be
equal to the its length (returned by Array.length(), that is toIndex-fromIndex.
type of elements of the returned array is the same
as the type of elements of this array.immutable,
trusted immutable or
copy-on-next-write, if, and only if,
this array is immutable, trusted immutable or copy-on-next-write correspondingly.UpdatableArray interface,
then the returned array also implements it.
If (and only if) this array implements DirectAccessible interface,
then the returned array also implements it.
The returned array never implements MutableArray interface;
it is always unresizable.Like List.subList method, this method eliminates the need
for explicit range operations.
For example, you may use Arrays.sort(UpdatableArray, ArrayComparator)
method for sorting a fragment of the array.
Unlike List.subList, the semantics of the array returned
by this method is well-defined in any case, even in case of
resizing of the source array.
Namely, if the internal storage of this or returned array is reallocated,
then the returned array will cease to be a view of this array.
The only possible reasons for reallocation are the following:
calling MutableArray.length(long),
MutableArray.ensureCapacity(long) or MutableArray.trim() methods
for this array, or any modification of this or returned array in a case when
this array is copy-on-next-write.
Also, if the length of this array will be reduced,
it can lead to clearing some elements in returned array:
see comments to MutableArray.length(long) method.
subArray in interface ArraysubArray in interface UpdatableArrayfromIndex - low endpoint (inclusive) of the subarray.toIndex - high endpoint (exclusive) of the subarray.Array.subArr(long, long)
UpdatablePArray subArr(long position,
long count)
ArraysubArray(position, position + count).
The only possible difference is other exception messages.
If position+count>Long.MAX_VALUE (overflow),
an exception message is allowed to be not fully correct
(maximal speed is more important than absolutely correct exception messages for such exotic situations).
subArr in interface ArraysubArr in interface UpdatableArrayposition - start position (inclusive) of the subarray.count - number of elements in the subarray.Array.subArray(long, long)UpdatablePArray asUnresizable()
UpdatableArrayThe returned view (when it is not a reference to this object) contains the same elements
as this array, but independent length, start offset, capacity, copy-on-next-write and
possible other information about array characteristics besides its elements,
as for UpdatableArray.shallowClone() method.
If modifications of this or returned array characteristics lead to reallocation
of the internal storage, then the returned array ceases to be a view of this array.
The only possible reasons for reallocation are the following:
calling MutableArray.length(long),
MutableArray.ensureCapacity(long) or MutableArray.trim() methods
for this array, or any modification of this or returned array in a case when
this array is copy-on-next-write.
Resizable arrays, created by this package, implement full MutableArray
interface, but unresizable ones implement only its UpdatableArray superinterface.
asUnresizable in interface UpdatableArrayArray.isUnresizable()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||