Class AbstractFloatArray
- All Implemented Interfaces:
Cloneable,Array,FloatArray,PArray,PFloatingArray,PNumberArray
- Direct Known Subclasses:
AbstractUpdatableFloatArray
Implementation of almost all basic functions of FloatArray interface.
The only FloatArray.getFloat(long) method is not defined in this class;
all other methods are implemented via calls of FloatArray.getFloat(long).
- Author:
- Daniel Alievsky
-
Field Summary
Fields inherited from class net.algart.arrays.AbstractArray
capacity, length, underlyingArrays -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFloatArray(long initialCapacityAndLength, boolean underlyingArraysAreParallel, Array... underlyingArrays) Equivalent to the constructorAbstractFloatArray(long, long, boolean, Array...), where both initialCapacity and initialLength arguments are equal to initialCapacityAndLength.protectedAbstractFloatArray(long initialCapacity, long initialLength, boolean underlyingArraysAreParallel, Array... underlyingArrays) Creates an array with the given initial capacity and length. -
Method Summary
Modifier and TypeMethodDescriptionThis implementation returns this object.This implementation returns this object.This implementation callsasImmutable()and returns its result.longReturn the number of memory bits occupied by every element of this array.buffer()This implementation returnsbuffer(suitableMode), where suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ.buffer(long capacity) This implementation returnsbuffer(suitableMode, capacity), where capacity is the argument of this method and suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ.buffer(DataBuffer.AccessMode mode) This implementation returnsbuffer(mode, someCapacity), where mode is the argument of this method and someCapacity is the result ofdefaultBufferCapacity(thisArray)method.buffer(DataBuffer.AccessMode mode, long capacity) This method is fully implemented in this class.voidThis implementation does nothing.Class<?>Returns the type of array elements.voidflushResources(ArrayContext context, boolean forcePhysicalWriting) This implementation callsflushResources(context, 0, length(), forcePhysicalWriting).protected voidflushResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting) This method implements all actions that should be performed by call.subArray(fromIndex, toIndex).flushResources(context, forcePhysicalWriting)voidfreeResources(ArrayContext context, boolean forcePhysicalWriting) This implementation callsfreeResources(context, 0, length()), forcePhysicalWriting).protected voidfreeResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting) This method implements all actions that should be performed by call.subArray(fromIndex, toIndex).freeResources(context, forcePhysicalWriting)voidThis implementation callsgetData(long, Object, int, int)with corresponding arguments.voidThis implementation is based on a loop of calls ofgetFloat(long)method.doublegetDouble(long index) Returns the element #index converted to double: (double)(value&0xFF) for byte value, (double)(value&0xFFFF) for short value, (double)value for int, long, float, double, char values, or value?1.0:0.0 for boolean values.getElement(long index) This implementation returns getFloat(index).abstract floatgetFloat(long index) Returns the element #index.longindexOf(long lowIndex, long highIndex, double value) This implementation returns value==(float)value ?indexOf(lowIndex, highIndex, (float)value) : -1.longindexOf(long lowIndex, long highIndex, float value) This implementation is based on a loop of calls ofgetFloat(long)method from index max(lowIndex,0) until index min(AbstractArray.length(),highIndex)-1.booleanThis implementation returns false.booleanThis implementation returns true.booleanThis implementation returns true.float[]ja()This implementation performs the following code:longlastIndexOf(long lowIndex, long highIndex, double value) This implementation returns value==(float)value ?lastIndexOf(lowIndex, highIndex, (float)value) : -1.longlastIndexOf(long lowIndex, long highIndex, float value) This implementation is based on a loop of calls ofgetFloat(long)method from index min(AbstractArray.length(),highIndex)-1 back until index max(lowIndex,0).voidloadResources(ArrayContext context) This implementation callsloadResources(context, 0, length()).protected voidloadResources(ArrayContext context, long fromIndex, long toIndex) This method implements all actions that should be performed by call.subArray(fromIndex, toIndex).loadResources(context)doublemaxPossibleValue(double valueForFloatingPoint) Returns 1 forBitArray, 0xFF forByteArray, 0xFFFF forCharArrayandShortArray, Integer.MAX_VALUE forIntArray, Long.MAX_VALUE forLongArray, valueForFloatingPoint forFloatArrayandDoubleArray.doubleminPossibleValue(double valueForFloatingPoint) Returns 0 forBitArray,ByteArray,CharArrayandShortArray, Integer.MIN_VALUE forIntArray, Long.MIN_VALUE forLongArray, valueForFloatingPoint forFloatArrayandDoubleArray.mutableClone(MemoryModel memoryModel) Class<? extends MutableFloatArray>Returns the canonical resizable AlgART type of arrays with the same element types: the class of one of 9 basic interfaces, describing all kinds of resizable AlgART arrays for 8 primitive and any non-primitive element types.subArray(long fromIndex, long toIndex) This implementation returns new instance ofAbstractFloatArraywith the same memory model, underlying arrays and underlyingArraysAreParallel flag, that were passed to the constructor of this instance, and with overridden methodsgetFloat(long)andgetData(long, Object, int, int), calling the same methods of this instance with corresponding corrections of the arguments.toString()Returns a brief string description of this object.Class<? extends FloatArray>type()Returns the canonical AlgART type of this array: the class of one of 9 basic interfaces, describing all kinds of AlgART arrays for 8 primitive and any non-primitive element types.updatableClone(MemoryModel memoryModel) This implementation performs the following: memoryModel.newUnresizableArray(thisArray).copy(thisArray).Class<? extends UpdatableFloatArray>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 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, shallowClone, standardObjectClone, subArrMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.algart.arrays.Array
byteOrder, capacity, equals, flushResources, freeResources, hashCode, isEmpty, isLazy, isNew, isNewReadOnlyView, length, length32, newJavaArray, shallowClone, subArrMethods inherited from interface net.algart.arrays.FloatArray
jaFloat, matrix
-
Constructor Details
-
AbstractFloatArray
protected AbstractFloatArray(long initialCapacity, long initialLength, boolean underlyingArraysAreParallel, Array... underlyingArrays) Creates an array with the given initial capacity and length.The underlyingArraysAreParallel informs whether the passed underlying arrays (if they exist) are "parallel" to this one and to each other. Intuitively, it means that every element #k of this array is connected (for example, depends on) the elements #k (of, maybe, #k±i, where i is little) of the underlying arrays. Precisely, this argument affects the following in this implementation:
- If it is true, then all passed underlying arrays (if underlyingArrays.length>1)
must have identical length — in other case, this constructor throws
SizeMismatchException. - If it is true, then
loadResources(ArrayContext context, long fromIndex, long toIndex),flushResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)andfreeResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)
loadResources(ArrayContext context),flushResources(ArrayContext context, boolean forcePhysicalWriting)andfreeResources(ArrayContext context, boolean forcePhysicalWriting)methods for the correspondingsubarraysof all underlying arrays. If this argument is false, thenloadResources(ArrayContext context, long fromIndex, long toIndex)does nothing,flushResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)andfreeResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)methods ignore their fromIndex / toIndex arguments and callloadResources(ArrayContext context),flushResources(ArrayContext context, boolean forcePhysicalWriting)andfreeResources(ArrayContext context, boolean forcePhysicalWriting)methods for original underlying arrays (not their subarrays).
loadResources(ArrayContext context, long fromIndex, long toIndex),flushResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)andfreeResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)methods and offer better implementations for subarrays, for example, that will work with suitable regions of the underlying arrays.
The created array is not
newby 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 callsetNewStatus(true)in the constructor of your subclass.The created array never has new-read-only-view status:
Array.isNewReadOnlyView()method always returns false in this class and its inheritors.- Parameters:
initialCapacity- initial capacity of the array.initialLength- initial length of the array.underlyingArraysAreParallel- whether the underlying arrays are "parallel" to this.underlyingArrays- see the same argument ofAbstractArray(long, long, Array...).- Throws:
NullPointerException- if underlyingArrays argument or some of underlyingArrays[k] elements is null.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.
- If it is true, then all passed underlying arrays (if underlyingArrays.length>1)
must have identical length — in other case, this constructor throws
-
AbstractFloatArray
protected AbstractFloatArray(long initialCapacityAndLength, boolean underlyingArraysAreParallel, Array... underlyingArrays) Equivalent to the constructorAbstractFloatArray(long, long, boolean, Array...), where both initialCapacity and initialLength arguments are equal to initialCapacityAndLength.- Parameters:
initialCapacityAndLength- initial capacity and length of the array.underlyingArraysAreParallel- seeAbstractFloatArray(long, long, boolean, Array...).underlyingArrays- seeAbstractFloatArray(long, long, boolean, Array...).- Throws:
NullPointerException- if underlyingArrays argument or some of underlyingArrays[k] elements is null.IllegalArgumentException- if initialCapacityAndLength argument is negative.SizeMismatchException- if underlyingArraysAreParallel=true, underlyingArrays.length>1 and some of passed arrays have different lengths.
-
-
Method Details
-
elementType
Description copied from interface:ArrayReturns the type of array elements. For arrays of primitive types, returns:- boolean.class for
BitArray, - char.class for
CharArray, - byte.class for
ByteArray, - short.class for
ShortArray, - int.class for
IntArray), - long.class for
LongArray, - float.class for
FloatArray, - double.class for
DoubleArray.
There is a guarantee that this method works very quickly (usually it just returns a value of some private field).
- Specified by:
elementTypein interfaceArray- Specified by:
elementTypein classAbstractArray- Returns:
- the type of array elements.
- See Also:
- boolean.class for
-
type
Description copied from interface:ArrayReturns the canonical AlgART type of this array: the class of one of 9 basic interfaces, describing all kinds of AlgART arrays for 8 primitive and any non-primitive element types. More precisely, returns:BitArray.class, if this object is an instance ofBitArray,CharArray.class, if this object is an instance ofCharArray,ByteArray.class, if this object is an instance ofByteArray,ShortArray.class, if this object is an instance ofShortArray,IntArray.class, if this object is an instance ofIntArray,LongArray.class, if this object is an instance ofLongArray,FloatArray.class, if this object is an instance ofFloatArray,DoubleArray.class, if this object is an instance ofDoubleArray,ObjectArray.class, if this object is an instance ofObjectArray.
There is a guarantee that this method works very quickly (usually it just returns a constant value).
- Specified by:
typein interfaceArray- Specified by:
typein interfaceFloatArray- Specified by:
typein interfacePArray- Specified by:
typein interfacePFloatingArray- Specified by:
typein interfacePNumberArray- Specified by:
typein classAbstractArray- Returns:
- canonical AlgART type of this array.
-
updatableType
Description copied from interface:ArrayReturns 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. More precisely, returns:UpdatableBitArray.class, if this object is an instance ofBitArray,UpdatableCharArray.class, if this object is an instance ofCharArray,UpdatableByteArray.class, if this object is an instance ofByteArray,UpdatableShortArray.class, if this object is an instance ofShortArray,UpdatableIntArray.class, if this object is an instance ofIntArray,UpdatableLongArray.class, if this object is an instance ofLongArray,UpdatableFloatArray.class, if this object is an instance ofFloatArray,UpdatableDoubleArray.class, if this object is an instance ofDoubleArray,UpdatableObjectArray.class, if this object is an instance ofObjectArray.
There is a guarantee that this method works very quickly (usually it just returns a constant value).
- Specified by:
updatableTypein interfaceArray- Specified by:
updatableTypein interfaceFloatArray- Specified by:
updatableTypein interfacePArray- Specified by:
updatableTypein interfacePFloatingArray- Specified by:
updatableTypein interfacePNumberArray- Specified by:
updatableTypein classAbstractArray- Returns:
- canonical AlgART type of an updatable array of the same kind.
-
mutableType
Description copied from interface:ArrayReturns the canonical resizable AlgART type of arrays with the same element types: the class of one of 9 basic interfaces, describing all kinds of resizable AlgART arrays for 8 primitive and any non-primitive element types. More precisely, returns:MutableBitArray.class, if this object is an instance ofBitArray,MutableCharArray.class, if this object is an instance ofCharArray,MutableByteArray.class, if this object is an instance ofByteArray,MutableShortArray.class, if this object is an instance ofShortArray,MutableIntArray.class, if this object is an instance ofIntArray,MutableLongArray.class, if this object is an instance ofLongArray,MutableFloatArray.class, if this object is an instance ofFloatArray,MutableDoubleArray.class, if this object is an instance ofDoubleArray,MutableObjectArray.class, if this object is an instance ofObjectArray.
There is a guarantee that this method works very quickly (usually it just returns a constant value).
- Specified by:
mutableTypein interfaceArray- Specified by:
mutableTypein interfaceFloatArray- Specified by:
mutableTypein interfacePArray- Specified by:
mutableTypein interfacePFloatingArray- Specified by:
mutableTypein interfacePNumberArray- Specified by:
mutableTypein classAbstractArray- Returns:
- canonical AlgART type of a resizable array of the same kind.
-
getData
This implementation is based on a loop of calls ofgetFloat(long)method. Please override this method if it's possible to perform the same task more efficiently than such a loop.- Specified by:
getDatain interfaceArray- Specified by:
getDatain classAbstractArray- Parameters:
arrayPos- starting position in this AlgART array.destArray- the target Java array.destArrayOffset- starting position in the target Java array.count- the number of elements to be copied.- Throws:
NullPointerException- if destArray argument is null.IllegalArgumentException- if destArray argument is not an array.IndexOutOfBoundsException- if copying would cause access of data outside this array or target array.ArrayStoreException- if destArray element type mismatches with this arrayelementType().ClassCastException- if destArray element type mismatches with this arrayelementType()(both this and ArrayStoreException are possible, depending on implementation).- See Also:
-
getData
This implementation callsgetData(long, Object, int, int)with corresponding arguments.- Specified by:
getDatain interfaceArray- Specified by:
getDatain classAbstractArray- Parameters:
arrayPos- starting position in this AlgART array.destArray- the target Java array.- Throws:
NullPointerException- if destArray argument is null.IllegalArgumentException- if destArray argument is not an array.IndexOutOfBoundsException- if arrayPos is out of range 0..length()-1.ArrayStoreException- if destArray element type mismatches with this arrayelementType().ClassCastException- if destArray element type mismatches with this arrayelementType()(both this and ArrayStoreException are possible, depending on implementation).- See Also:
-
getElement
This implementation returns getFloat(index).- Specified by:
getElementin interfaceArray- Specified by:
getElementin classAbstractArray- Parameters:
index- index of element to get.- Returns:
- the element at the specified position in this array.
- Throws:
IndexOutOfBoundsException- if index is out of range 0..length()-1.
-
subArray
This implementation returns new instance ofAbstractFloatArraywith the same memory model, underlying arrays and underlyingArraysAreParallel flag, that were passed to the constructor of this instance, and with overridden methodsgetFloat(long)andgetData(long, Object, int, int), calling the same methods of this instance with corresponding corrections of the arguments.The returned instance also have overridden methods
loadResources(ArrayContext, long, long),flushResources(ArrayContext, long, long, boolean)andfreeResources(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.- Specified by:
subArrayin interfaceArray- Specified by:
subArrayin classAbstractArray- Parameters:
fromIndex- low endpoint (inclusive) of the subarray.toIndex- high endpoint (exclusive) of the subarray.- Returns:
- a view of the specified range within this array.
- Throws:
IndexOutOfBoundsException- for illegal fromIndex and toIndex (fromIndex < 0 || toIndex > length() || fromIndex > toIndex).- See Also:
-
buffer
Description copied from class:AbstractArrayThis method is fully implemented in this class.The returned buffer will be direct, if mode is not
PRIVATE, this array is notimmutable, is notcopy-on-next-write, and either it implementsDirectAccessibleinterface and itshasJavaArray()method returns true, or it is a bit array created by thesimple memory model.- Specified by:
bufferin interfaceArray- Specified by:
bufferin interfaceFloatArray- Overrides:
bufferin classAbstractArray- Parameters:
mode- the access mode for new buffer.capacity- the capacity of the buffer- Returns:
- new data buffer for accessing this array.
- See Also:
-
buffer
Description copied from class:AbstractArrayThis implementation returnsbuffer(mode, someCapacity), where mode is the argument of this method and someCapacity is the result ofdefaultBufferCapacity(thisArray)method.- Specified by:
bufferin interfaceArray- Specified by:
bufferin interfaceFloatArray- Overrides:
bufferin classAbstractArray- Parameters:
mode- the access mode for new buffer.- Returns:
- new data buffer for accessing this array.
-
buffer
Description copied from class:AbstractArrayThis implementation returnsbuffer(suitableMode, capacity), where capacity is the argument of this method and suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ.- Specified by:
bufferin interfaceArray- Specified by:
bufferin interfaceFloatArray- Overrides:
bufferin classAbstractArray- Parameters:
capacity- the capacity of the buffer.- Returns:
- new data buffer for accessing this array.
-
buffer
Description copied from class:AbstractArrayThis implementation returnsbuffer(suitableMode), where suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ.- Specified by:
bufferin interfaceArray- Specified by:
bufferin interfaceFloatArray- Overrides:
bufferin classAbstractArray- Returns:
- new data buffer for accessing this array.
-
bitsPerElement
public long bitsPerElement()Description copied from interface:PArrayReturn the number of memory bits occupied by every element of this array. The amount of memory used by the array can be estimated asArray.capacity()*bitsPerElement()/8 bytes (when the array capacity is large enough).If the number of occupied bits is not defined (for example, may depend on JVM implementation), this method returns -1.
For implementations from this package, this method returns:
- 1 for
BitArray(the value ofArrays.BITS_PER_BITconstant), - 16 for
CharArray(the value ofArrays.BITS_PER_CHARconstant), - 8 for
ByteArray(the value ofArrays.BITS_PER_BYTEconstant), - 16 for
ShortArray(the value ofArrays.BITS_PER_SHORTconstant), - 32 for
IntArray(the value ofArrays.BITS_PER_INTconstant), - 64 for
LongArray(the value ofArrays.BITS_PER_LONGconstant), - 32 for
FloatArray(the value ofArrays.BITS_PER_FLOATconstant), - 64 for
DoubleArray(the value ofArrays.BITS_PER_DOUBLEconstant).
(-1 result is never returned by implementations from this package.)
Please keep in mind that the real amount of occupied memory, theoretically, can differ from the value returned by this method. For example, some JVM, theoretically, may store byte elements of byte[] array in 32-bit memory words. In this case, this method will return invalid result for byte arrays created by the
simple memory model. However: we guarantee the results of this method are always correct for arrays created by thebuffer memory modelandlarge memory model.There is a guarantee that this method works very quickly (usually it just returns a constant or a value of some private field).
- Specified by:
bitsPerElementin interfacePArray- Returns:
- the number of bytes occupied by every element of this array, or -1 if it cannot be determined.
- See Also:
- 1 for
-
getDouble
public double getDouble(long index) Description copied from interface:PArrayReturns the element #index converted to double: (double)(value&0xFF) for byte value, (double)(value&0xFFFF) for short value, (double)value for int, long, float, double, char values, or value?1.0:0.0 for boolean values. Please note that this method returns unsigned values for byte and short arrays. Returned value contains full information stored in the element, excepting the case of very large long elements. -
indexOf
public long indexOf(long lowIndex, long highIndex, double value) This implementation returns value==(float)value ?indexOf(lowIndex, highIndex, (float)value) : -1.- Specified by:
indexOfin interfacePArray- Parameters:
lowIndex- the low index in the array for search (inclusive).highIndex- the high index in the array for search (exclusive).value- the value to be found.- Returns:
- the index of the first occurrence of this value in this array in range lowIndex<=index<highIndex, or -1 if this value does not occur in this range.
-
lastIndexOf
public long lastIndexOf(long lowIndex, long highIndex, double value) This implementation returns value==(float)value ?lastIndexOf(lowIndex, highIndex, (float)value) : -1.- Specified by:
lastIndexOfin interfacePArray- Parameters:
lowIndex- the low index in the array for search (inclusive).highIndex- the high index in the array for search (exclusive).value- the value to be found.- Returns:
- the index of the last occurrence of this value in this array in range lowIndex<=index<highIndex, or -1 if this value does not occur in this range.
-
getFloat
public abstract float getFloat(long index) Description copied from interface:FloatArrayReturns the element #index.- Specified by:
getFloatin interfaceFloatArray- Parameters:
index- index of element to get.- Returns:
- the element at the specified position in this array.
-
indexOf
public long indexOf(long lowIndex, long highIndex, float value) This implementation is based on a loop of calls ofgetFloat(long)method from index max(lowIndex,0) until index min(AbstractArray.length(),highIndex)-1. Please override this method if it's possible to perform the same task more efficiently than such a loop.- Specified by:
indexOfin interfaceFloatArray- Parameters:
lowIndex- the low index in the array for search (inclusive).highIndex- the high index in the array for search (exclusive).value- the value to be found.- Returns:
- the index of the first occurrence of this value in this array in range lowIndex<=index<highIndex, or -1 if this value does not occur in this range.
-
lastIndexOf
public long lastIndexOf(long lowIndex, long highIndex, float value) This implementation is based on a loop of calls ofgetFloat(long)method from index min(AbstractArray.length(),highIndex)-1 back until index max(lowIndex,0). Please override this method if it's possible to perform the same task more efficiently than such a loop.- Specified by:
lastIndexOfin interfaceFloatArray- Parameters:
lowIndex- the low index in the array for search (inclusive).highIndex- the high index in the array for search (exclusive).value- the value to be found.- Returns:
- the index of the last occurrence of this value in this array in range lowIndex<=index<highIndex, or -1 if this value does not occur in this range.
-
isImmutable
public boolean isImmutable()This implementation returns true. Should be overridden if the inheritor is mutable.- Specified by:
isImmutablein interfaceArray- Specified by:
isImmutablein classAbstractArray- Returns:
- true if this instance is immutable.
- See Also:
-
isUnresizable
public boolean isUnresizable()This implementation returns true. Should be overridden if the inheritor is resizable- Specified by:
isUnresizablein interfaceArray- Specified by:
isUnresizablein classAbstractArray- Returns:
- true if this instance is unresizable.
- See Also:
-
checkUnallowedMutation
This implementation does nothing.- Specified by:
checkUnallowedMutationin interfaceArray- Specified by:
checkUnallowedMutationin classAbstractArray- Throws:
UnallowedMutationError- never in this implementation.- See Also:
-
asTrustedImmutable
This implementation callsasImmutable()and returns its result.- Specified by:
asTrustedImmutablein interfaceArray- Specified by:
asTrustedImmutablein interfaceFloatArray- Specified by:
asTrustedImmutablein interfacePArray- Specified by:
asTrustedImmutablein interfacePFloatingArray- Specified by:
asTrustedImmutablein classAbstractArray- Returns:
- a trusted immutable view of this array (or a reference to this array if it is already trusted immutable).
- See Also:
-
asCopyOnNextWrite
This implementation returns this object. Should be overridden if the inheritor is mutable.- Specified by:
asCopyOnNextWritein interfaceArray- Specified by:
asCopyOnNextWritein classAbstractArray- Returns:
- a copy-on-next-write view of this array (or a reference to this array if it is immutable or already copy-on-next-write).
- See Also:
-
isCopyOnNextWrite
public boolean isCopyOnNextWrite()This implementation returns false. Should be overridden if the inheritor is mutable.- Specified by:
isCopyOnNextWritein interfaceArray- Specified by:
isCopyOnNextWritein classAbstractArray- Returns:
- true if this array is in copy-on-next-write mode
- See Also:
-
asImmutable
This implementation returns this object. Should be overridden if the inheritor is mutable.- Specified by:
asImmutablein interfaceArray- Specified by:
asImmutablein interfaceFloatArray- Specified by:
asImmutablein interfacePArray- Specified by:
asImmutablein interfacePFloatingArray- Specified by:
asImmutablein classAbstractArray- Returns:
- an immutable view of this array (or a reference to this array if it is immutable).
- See Also:
-
mutableClone
Description copied from class:AbstractArray- Specified by:
mutableClonein interfaceArray- Specified by:
mutableClonein interfaceFloatArray- Specified by:
mutableClonein interfacePArray- Specified by:
mutableClonein interfacePFloatingArray- Overrides:
mutableClonein classAbstractArray- Parameters:
memoryModel- the memory model, used for allocation a new copy of this array.- Returns:
- a mutable copy of this array.
- See Also:
-
updatableClone
Description copied from class:AbstractArrayThis implementation performs the following: memoryModel.newUnresizableArray(thisArray).copy(thisArray).- Specified by:
updatableClonein interfaceArray- Specified by:
updatableClonein interfaceFloatArray- Specified by:
updatableClonein interfacePArray- Specified by:
updatableClonein interfacePFloatingArray- Overrides:
updatableClonein classAbstractArray- Parameters:
memoryModel- the memory model, used for allocation a new copy of this array.- Returns:
- an updatable copy of this array.
- See Also:
-
ja
public float[] ja()Description copied from class:AbstractArrayThis implementation performs the following code:return this instanceof DirectAccessible da && da.hasJavaArray() && da.javaArrayOffset() == 0 && java.lang.reflect.Array.getLength(da.javaArray()) == this.length() ? da.javaArray() : Arrays.toJavaArray(this);- Specified by:
jain interfaceArray- Specified by:
jain interfaceFloatArray- Overrides:
jain classAbstractArray- Returns:
- Java array, equivalent to this AlgART array.
- See Also:
-
loadResources
This implementation callsloadResources(context, 0, length()).- Specified by:
loadResourcesin interfaceArray- Overrides:
loadResourcesin classAbstractArray- Parameters:
context- the context of execution; may be null, then it will be ignored.- See Also:
-
flushResources
This implementation callsflushResources(context, 0, length(), forcePhysicalWriting).- Specified by:
flushResourcesin interfaceArray- Overrides:
flushResourcesin classAbstractArray- Parameters:
context- the context of execution; may be null, then it will be ignored.forcePhysicalWriting- is it necessary to try forcing physical writing all associated resources to the external device.- See Also:
-
freeResources
This implementation callsfreeResources(context, 0, length()), forcePhysicalWriting).- Specified by:
freeResourcesin interfaceArray- Overrides:
freeResourcesin classAbstractArray- Parameters:
context- the context of execution; may be null, then it will be ignored.forcePhysicalWriting- is it necessary to try forcing physical writing all associated resources to the external device.- See Also:
-
loadResources
This method implements all actions that should be performed by call. This default implementation callssubArray(fromIndex, toIndex).loadResources(context)loadResources(c)(where c is a necessarypartof the passed context) for the corresponding subarray of all underlying arrays, passed via the last argument of the constructor, if the underlyingArraysAreParallel constructor argument was true, or does nothing in other case.- Parameters:
context- the context of execution; may be null, then it will be ignored.fromIndex- low endpoint (inclusive) of the subarray that should be loaded.toIndex- high endpoint (exclusive) of the subarray that should be loaded.- Throws:
IndexOutOfBoundsException- for illegal fromIndex and toIndex (fromIndex < 0 || toIndex > length() || fromIndex > toIndex).
-
flushResources
protected void flushResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting) This method implements all actions that should be performed by call. This default implementation callssubArray(fromIndex, toIndex).flushResources(context, forcePhysicalWriting)flushResources(c, forcePhysicalWriting)(where c is a necessarypartof the passed context) for the corresponding subarray of all underlying arrays, passed via the last argument of the constructor, if the underlyingArraysAreParallel constructor argument was true, or for original underlying arrays in other case (alikeAbstractArray.flushResources(ArrayContext, boolean)).- Parameters:
context- the context of execution; may be null, then it will be ignored.fromIndex- low endpoint (inclusive) of the subarray that should be flushed.toIndex- high endpoint (exclusive) of the subarray that should be flushed.forcePhysicalWriting- is it necessary to try forcing physical writing all associated resources to the external device.- Throws:
IndexOutOfBoundsException- for illegal fromIndex and toIndex (fromIndex < 0 || toIndex > length() || fromIndex > toIndex).
-
freeResources
protected void freeResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting) This method implements all actions that should be performed by call. This default implementation callssubArray(fromIndex, toIndex).freeResources(context, forcePhysicalWriting)freeResources(c, forcePhysicalWriting)(where c is a necessarypartof the passed context) for the corresponding subarray of all underlying arrays, passed via the last argument of the constructor, if the underlyingArraysAreParallel constructor argument was true, or for original underlying arrays in other case (alikeAbstractArray.freeResources(ArrayContext, boolean)).- Parameters:
context- the context of execution; may be null, then it will be ignored.fromIndex- low endpoint (inclusive) of the subarray that should be freed.toIndex- high endpoint (exclusive) of the subarray that should be freed.forcePhysicalWriting- is it necessary to try forcing physical writing all associated resources to the external device.- Throws:
IndexOutOfBoundsException- for illegal fromIndex and toIndex (fromIndex < 0 || toIndex > length() || fromIndex > toIndex).
-
toString
Description copied from interface:ArrayReturns a brief string description of this object.The 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 useArrays.toString(CharArray)method.- Specified by:
toStringin interfaceArray- Specified by:
toStringin classAbstractArray- Returns:
- a brief string description of this object.
-
minPossibleValue
public double minPossibleValue(double valueForFloatingPoint) Description copied from interface:PArrayReturns 0 forBitArray,ByteArray,CharArrayandShortArray, Integer.MIN_VALUE forIntArray, Long.MIN_VALUE forLongArray, valueForFloatingPoint forFloatArrayandDoubleArray. Forfixed-point arraysit is the minimal possible value, that can stored in elements of this array (byte and short elements are interpreted as unsigned). This method is equivalent tominPossibleValue(thisArray.getClass(), valueForFloatingPoint).- Specified by:
minPossibleValuein interfacePArray- Parameters:
valueForFloatingPoint- the value returned for floating-point array type.- Returns:
- the minimal possible value, that can stored in elements of this array, if it is a fixed-point array, or the argument for floating-point arrays.
- See Also:
-
maxPossibleValue
public double maxPossibleValue(double valueForFloatingPoint) Description copied from interface:PArrayReturns 1 forBitArray, 0xFF forByteArray, 0xFFFF forCharArrayandShortArray, Integer.MAX_VALUE forIntArray, Long.MAX_VALUE forLongArray, valueForFloatingPoint forFloatArrayandDoubleArray. Forfixed-point arraysit is the maximal possible value, that can stored in elements of this array (byte and short elements are interpreted as unsigned). This method is equivalent tomaxPossibleValue(thisArray.getClass(), valueForFloatingPoint).- Specified by:
maxPossibleValuein interfacePArray- Parameters:
valueForFloatingPoint- the value returned for floating-point array type.- Returns:
- the maximal possible value, that can stored in elements of this array, if it is a fixed-point array, or the argument for floating-point arrays.
- See Also:
-