AlgART Home

net.algart.arrays
Class AbstractFloatArray

java.lang.Object
  extended by net.algart.arrays.AbstractArray
      extended by net.algart.arrays.AbstractFloatArray
All Implemented Interfaces:
java.lang.Cloneable, Array, FloatArray, PArray, PFloatingArray, PNumberArray
Direct Known Subclasses:
AbstractUpdatableFloatArray

public abstract class AbstractFloatArray
extends AbstractArray
implements FloatArray

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).

AlgART Laboratory 2007-2013

Since:
JDK 1.5
Version:
1.2
Author:
Daniel Alievsky

Field Summary
Modifier and Type Field and Description
 
Fields inherited from class net.algart.arrays.AbstractArray
capacity, length, underlyingArrays
 
Constructor Summary
Modifier Constructor and Description
protected AbstractFloatArray(long initialCapacityAndLength, boolean underlyingArraysAreParallel, Array... underlyingArrays)
          Equivalent to the constructor AbstractFloatArray(long, long, boolean, Array...), where both initialCapacity and initialLength arguments are equal to initialCapacityAndLength.
protected AbstractFloatArray(long initialCapacity, long initialLength, boolean underlyingArraysAreParallel, Array... underlyingArrays)
          Creates an array with the given initial capacity and length.
 
Method Summary
Modifier and Type Method and Description
 Array asCopyOnNextWrite()
          This implementation returns this object.
 FloatArray asImmutable()
          This implementation returns this object.
 FloatArray asTrustedImmutable()
          This implementation calls asImmutable() and returns its result.
 long bitsPerElement()
          Return the number of memory bits occupied by every element of this array.
 DataFloatBuffer buffer()
          This implementation returns buffer(suitableMode), where suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ.
 DataFloatBuffer buffer(DataBuffer.AccessMode mode)
          This implementation returns buffer(mode, someCapacity), where mode is the argument of this method and someCapacity is the result of defaultBufferCapacity(thisArray) method.
 DataFloatBuffer buffer(DataBuffer.AccessMode mode, long capacity)
          This method is fully implemented in this class.
 DataFloatBuffer buffer(long capacity)
          This implementation returns buffer(suitableMode, capacity), where capacity is the argument of this method and suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ.
 void checkUnallowedMutation()
          This implementation does nothing.
 java.lang.Class<?> elementType()
          Returns the type of array elements.
 void flushResources(ArrayContext context, boolean forcePhysicalWriting)
          This implementation calls flushResources(context, 0, length(), forcePhysicalWriting).
protected  void flushResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)
          This method implements all actions that should be performed by subArray(fromIndex, toIndex).flushResources(context, forcePhysicalWriting) call.
 void freeResources(ArrayContext context, boolean forcePhysicalWriting)
          This implementation calls freeResources(context, 0, length()), forcePhysicalWriting).
protected  void freeResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting)
          This method implements all actions that should be performed by subArray(fromIndex, toIndex).freeResources(context, forcePhysicalWriting) call.
 void getData(long arrayPos, java.lang.Object destArray)
          This implementation calls getData(long, Object, int, int) with corresponding arguments.
 void getData(long arrayPos, java.lang.Object destArray, int destArrayOffset, int count)
          This implementation is based on a loop of calls of getFloat(long) method.
 double getDouble(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.
 java.lang.Object getElement(long index)
          This implementation returns getFloat(index).
abstract  float getFloat(long index)
          Returns the element #index.
 long indexOf(long lowIndex, long highIndex, double value)
          This implementation returns value==(float)value ? indexOf(lowIndex, highIndex, (float)value) : -1.
 long indexOf(long lowIndex, long highIndex, float value)
          This implementation is based on a loop of calls of getFloat(long) method from index max(lowIndex,0) until index min(AbstractArray.length(),highIndex)-1.
 boolean isCopyOnNextWrite()
          This implementation returns false.
 boolean isImmutable()
          This implementation returns true.
 boolean isUnresizable()
          This implementation returns true.
 long lastIndexOf(long lowIndex, long highIndex, double value)
          This implementation returns value==(float)value ? lastIndexOf(lowIndex, highIndex, (float)value) : -1.
 long lastIndexOf(long lowIndex, long highIndex, float value)
          This implementation is based on a loop of calls of getFloat(long) method from index min(AbstractArray.length(),highIndex)-1 back until index max(lowIndex,0).
 void loadResources(ArrayContext context)
          This implementation calls loadResources(context, 0, length()).
protected  void loadResources(ArrayContext context, long fromIndex, long toIndex)
          This method implements all actions that should be performed by subArray(fromIndex, toIndex).loadResources(context) call.
 double maxPossibleValue(double valueForFloatingPoint)
          Returns 1 for BitArray, 0xFF for ByteArray, 0xFFFF for CharArray and ShortArray, Integer.MAX_VALUE for IntArray, Long.MAX_VALUE for LongArray, valueForFloatingPoint for FloatArray and DoubleArray.
 double minPossibleValue(double valueForFloatingPoint)
          Returns 0 for BitArray, ByteArray, CharArray and ShortArray, Integer.MIN_VALUE for IntArray, Long.MIN_VALUE for LongArray, valueForFloatingPoint for FloatArray and DoubleArray.
 MutableFloatArray mutableClone(MemoryModel memoryModel)
          This implementation performs the following: memoryModel.newArray(thisArray).copy(thisArray).
 java.lang.Class<? extends MutableFloatArray> mutableType()
          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.
 Array subArray(long fromIndex, long toIndex)
          This implementation returns new instance of AbstractFloatArray with the same memory model, underlying arrays and underlyingArraysAreParallel flag, that were passed to the constructor of this instance, and with overridden methods getFloat(long) and getData(long, Object, int, int), calling the same methods of this instance with corresponding corrections of the arguments.
 java.lang.String toString()
          Returns a brief string description of this object.
 java.lang.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.
 UpdatableFloatArray updatableClone(MemoryModel memoryModel)
          This implementation performs the following: memoryModel.newUnresizableArray(thisArray).copy(thisArray).
 java.lang.Class<? extends UpdatableFloatArray> 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 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, subArr
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.algart.arrays.PArray
isZeroFilled
 
Methods inherited from interface net.algart.arrays.Array
byteOrder, capacity, equals, flushResources, freeResources, hashCode, isLazy, isNew, isNewReadOnlyView, length, newJavaArray, shallowClone, subArr
 

Constructor Detail

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:

  1. If it is true, then all passed underlying arrays (if underlyingArrays.length>1) must have identical length — in other case, this constructor throws SizeMismatchException.
  2. If it is true, then methods call loadResources(ArrayContext context), flushResources(ArrayContext context, boolean forcePhysicalWriting) and freeResources(ArrayContext context, boolean forcePhysicalWriting) methods for the corresponding subarrays of all underlying arrays. If this argument is false, thenOf course, if you specify underlyingArraysAreParallel=false, you can override loadResources(ArrayContext context, long fromIndex, long toIndex), flushResources(ArrayContext context, long fromIndex, long toIndex, boolean forcePhysicalWriting) and freeResources(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 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.

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 of AbstractArray.AbstractArray(long, long, Array...).
Throws:
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.

AbstractFloatArray

protected AbstractFloatArray(long initialCapacityAndLength,
                             boolean underlyingArraysAreParallel,
                             Array... underlyingArrays)
Equivalent to the constructor AbstractFloatArray(long, long, boolean, Array...), where both initialCapacity and initialLength arguments are equal to initialCapacityAndLength.

Parameters:
initialCapacityAndLength - initial capacity and length of the array.
underlyingArraysAreParallel - see AbstractFloatArray(long, long, boolean, Array...).
underlyingArrays - see AbstractFloatArray(long, long, boolean, Array...).
Throws:
java.lang.NullPointerException - if underlyingArrays argument or some of underlyingArrays[k] elements is null.
java.lang.IllegalArgumentException - if initialCapacityAndLength argument is negative.
SizeMismatchException - if underlyingArraysAreParallel=true, underlyingArrays.length>1 and some of passed arrays have different lengths.
Method Detail

elementType

public java.lang.Class<?> elementType()
Description copied from interface: Array
Returns the type of array elements. For arrays of primitive types, returns: All elements of the array are values of this type or (for non-primitive types) some inheritor of this type.

There is a guarantee that this method works very quickly (usually it just returns a value of some private field).

Specified by:
elementType in interface Array
Specified by:
elementType in class AbstractArray
Returns:
the type of array elements.
See Also:
Arrays.elementType(Class)

type

public java.lang.Class<? extends FloatArray> type()
Description copied from interface: Array
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. More precisely, returns:

There is a guarantee that this method works very quickly (usually it just returns a constant value).

Specified by:
type in interface Array
Specified by:
type in interface FloatArray
Specified by:
type in interface PArray
Specified by:
type in interface PFloatingArray
Specified by:
type in interface PNumberArray
Specified by:
type in class AbstractArray
Returns:
canonical AlgART type of this array.

updatableType

public java.lang.Class<? extends UpdatableFloatArray> updatableType()
Description copied from interface: Array
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. More precisely, returns:

There is a guarantee that this method works very quickly (usually it just returns a constant value).

Specified by:
updatableType in interface Array
Specified by:
updatableType in interface FloatArray
Specified by:
updatableType in interface PArray
Specified by:
updatableType in interface PFloatingArray
Specified by:
updatableType in interface PNumberArray
Specified by:
updatableType in class AbstractArray
Returns:
canonical AlgART type of an updatable array of the same kind.

mutableType

public java.lang.Class<? extends MutableFloatArray> mutableType()
Description copied from interface: Array
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. More precisely, returns:

There is a guarantee that this method works very quickly (usually it just returns a constant value).

Specified by:
mutableType in interface Array
Specified by:
mutableType in interface FloatArray
Specified by:
mutableType in interface PArray
Specified by:
mutableType in interface PFloatingArray
Specified by:
mutableType in interface PNumberArray
Specified by:
mutableType in class AbstractArray
Returns:
canonical AlgART type of a resizable array of the same kind.

getData

public void getData(long arrayPos,
                    java.lang.Object destArray,
                    int destArrayOffset,
                    int count)
This implementation is based on a loop of calls of getFloat(long) method. Please override this method if it's possible to perform the same task more efficiently than such a loop.

Specified by:
getData in interface Array
Specified by:
getData in class AbstractArray
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:
java.lang.NullPointerException - if destArray argument is null.
java.lang.IllegalArgumentException - if destArray argument is not an array.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside this array or target 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).
See Also:
DirectAccessible, UpdatableArray.setData(long, Object, int, int), BitArray.getBits(long, long[], long, long)

getData

public void getData(long arrayPos,
                    java.lang.Object destArray)
This implementation calls getData(long, Object, int, int) with corresponding arguments.

Specified by:
getData in interface Array
Specified by:
getData in class AbstractArray
Parameters:
arrayPos - starting position in this AlgART array.
destArray - the target Java array.
Throws:
java.lang.NullPointerException - if destArray argument is null.
java.lang.IllegalArgumentException - if destArray argument is not an array.
java.lang.IndexOutOfBoundsException - if arrayPos is out of range 0..length()-1.
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).
See Also:
DirectAccessible, Array.getData(long, Object, int, int), UpdatableArray.setData(long, Object)

getElement

public java.lang.Object getElement(long index)
This implementation returns getFloat(index).

Specified by:
getElement in interface Array
Specified by:
getElement in class AbstractArray
Parameters:
index - index of element to get.
Returns:
the element at the specified position in this array.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range 0..length()-1.

subArray

public Array subArray(long fromIndex,
                      long toIndex)
This implementation returns new instance of AbstractFloatArray with the same memory model, underlying arrays and underlyingArraysAreParallel flag, that were passed to the constructor of this instance, and with overridden methods getFloat(long) and getData(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) and 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.

Specified by:
subArray in interface Array
Specified by:
subArray in class AbstractArray
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:
java.lang.IndexOutOfBoundsException - for illegal fromIndex and toIndex (fromIndex < 0 || toIndex > length() || fromIndex > toIndex).
See Also:
Array.subArr(long, long)

buffer

public DataFloatBuffer buffer(DataBuffer.AccessMode mode,
                              long capacity)
Description copied from class: AbstractArray
This method is fully implemented in this class.

The returned buffer will be direct, if mode is not PRIVATE, this array is not immutable, is not copy-on-next-write, and either it implements DirectAccessible interface and its hasJavaArray() method returns true, or it is a bit array created by the simple memory model.

Specified by:
buffer in interface Array
Specified by:
buffer in interface FloatArray
Overrides:
buffer in class AbstractArray
Parameters:
mode - the access mode for new buffer.
capacity - the capacity of the buffer
Returns:
new data buffer for accessing this array.
See Also:
Array.buffer(net.algart.arrays.DataBuffer.AccessMode), Array.buffer(long), Array.buffer()

buffer

public DataFloatBuffer buffer(DataBuffer.AccessMode mode)
Description copied from class: AbstractArray
This implementation returns buffer(mode, someCapacity), where mode is the argument of this method and someCapacity is the result of defaultBufferCapacity(thisArray) method.

Specified by:
buffer in interface Array
Specified by:
buffer in interface FloatArray
Overrides:
buffer in class AbstractArray
Parameters:
mode - the access mode for new buffer.
Returns:
new data buffer for accessing this array.

buffer

public DataFloatBuffer buffer(long capacity)
Description copied from class: AbstractArray
This implementation returns buffer(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:
buffer in interface Array
Specified by:
buffer in interface FloatArray
Overrides:
buffer in class AbstractArray
Parameters:
capacity - the capacity of the buffer.
Returns:
new data buffer for accessing this array.

buffer

public DataFloatBuffer buffer()
Description copied from class: AbstractArray
This implementation returns buffer(suitableMode), where suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ.

Specified by:
buffer in interface Array
Specified by:
buffer in interface FloatArray
Overrides:
buffer in class AbstractArray
Returns:
new data buffer for accessing this array.

bitsPerElement

public long bitsPerElement()
Description copied from interface: PArray
Return the number of memory bits occupied by every element of this array. The amount of memory used by the array can be estimated as Array.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 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 the buffer memory model and large 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:
bitsPerElement in interface PArray
Returns:
the number of bytes occupied by every element of this array, or -1 if it cannot be determined.
See Also:
Arrays.bitsPerElement(Class)

getDouble

public double getDouble(long index)
Description copied from interface: PArray
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. Please note that this method returns unsigned values for byte and short arrays. Returned value contains full information stored in the element, excepting a case of very large long elements.

Specified by:
getDouble in interface PArray
Parameters:
index - index of element to get.
Returns:
the element at the specified position in this array.
See Also:
UpdatablePArray.setDouble(long, double)

indexOf

public long indexOf(long lowIndex,
                    long highIndex,
                    double value)
This implementation returns value==(float)value ? indexOf(lowIndex, highIndex, (float)value) : -1.

Specified by:
indexOf in interface PArray
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:
lastIndexOf in interface PArray
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: FloatArray
Returns the element #index.

Specified by:
getFloat in interface FloatArray
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 of getFloat(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:
indexOf in interface FloatArray
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 of getFloat(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:
lastIndexOf in interface FloatArray
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:
isImmutable in interface Array
Specified by:
isImmutable in class AbstractArray
Returns:
true if this instance is immutable.
See Also:
Array.asImmutable()

isUnresizable

public boolean isUnresizable()
This implementation returns true. Should be overridden if the inheritor is resizable

Specified by:
isUnresizable in interface Array
Specified by:
isUnresizable in class AbstractArray
Returns:
true if this instance is unresizable.
See Also:
UpdatableArray.asUnresizable()

checkUnallowedMutation

public void checkUnallowedMutation()
                            throws UnallowedMutationError
This implementation does nothing.

Specified by:
checkUnallowedMutation in interface Array
Specified by:
checkUnallowedMutation in class AbstractArray
Throws:
UnallowedMutationError - never in this implementation.
See Also:
Array.asTrustedImmutable()

asTrustedImmutable

public FloatArray asTrustedImmutable()
This implementation calls asImmutable() and returns its result.

Specified by:
asTrustedImmutable in interface Array
Specified by:
asTrustedImmutable in interface FloatArray
Specified by:
asTrustedImmutable in interface PArray
Specified by:
asTrustedImmutable in interface PFloatingArray
Specified by:
asTrustedImmutable in class AbstractArray
Returns:
a trusted immutable view of this array (or a reference to this array if it is already trusted immutable).
See Also:
Array.asImmutable(), Array.checkUnallowedMutation()

asCopyOnNextWrite

public Array asCopyOnNextWrite()
This implementation returns this object. Should be overridden if the inheritor is mutable.

Specified by:
asCopyOnNextWrite in interface Array
Specified by:
asCopyOnNextWrite in class AbstractArray
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:
Array.isCopyOnNextWrite(), MemoryModel.newLazyCopy(Array), MemoryModel.newUnresizableLazyCopy(Array)

isCopyOnNextWrite

public boolean isCopyOnNextWrite()
This implementation returns false. Should be overridden if the inheritor is mutable.

Specified by:
isCopyOnNextWrite in interface Array
Specified by:
isCopyOnNextWrite in class AbstractArray
Returns:
true if this array is in copy-on-next-write mode
See Also:
Array.asCopyOnNextWrite()

asImmutable

public FloatArray asImmutable()
This implementation returns this object. Should be overridden if the inheritor is mutable.

Specified by:
asImmutable in interface Array
Specified by:
asImmutable in interface FloatArray
Specified by:
asImmutable in interface PArray
Specified by:
asImmutable in interface PFloatingArray
Specified by:
asImmutable in class AbstractArray
Returns:
an immutable view of this array (or a reference to this array if it is immutable).
See Also:
Array.isImmutable(), Array.asTrustedImmutable(), Array.mutableClone(MemoryModel), Array.updatableClone(MemoryModel), UpdatableArray.asUnresizable()

mutableClone

public MutableFloatArray mutableClone(MemoryModel memoryModel)
Description copied from class: AbstractArray
This implementation performs the following: memoryModel.newArray(thisArray).copy(thisArray).

Specified by:
mutableClone in interface Array
Specified by:
mutableClone in interface FloatArray
Specified by:
mutableClone in interface PArray
Specified by:
mutableClone in interface PFloatingArray
Overrides:
mutableClone in class AbstractArray
Parameters:
memoryModel - the memory model, used for allocation a new copy of this array.
Returns:
a mutable copy of this array.
See Also:
Array.updatableClone(MemoryModel)

updatableClone

public UpdatableFloatArray updatableClone(MemoryModel memoryModel)
Description copied from class: AbstractArray
This implementation performs the following: memoryModel.newUnresizableArray(thisArray).copy(thisArray).

Specified by:
updatableClone in interface Array
Specified by:
updatableClone in interface FloatArray
Specified by:
updatableClone in interface PArray
Specified by:
updatableClone in interface PFloatingArray
Overrides:
updatableClone in class AbstractArray
Parameters:
memoryModel - the memory model, used for allocation a new copy of this array.
Returns:
an updatable copy of this array.
See Also:
Array.mutableClone(MemoryModel)

loadResources

public void loadResources(ArrayContext context)
This implementation calls loadResources(context, 0, length()).

Specified by:
loadResources in interface Array
Overrides:
loadResources in class AbstractArray
Parameters:
context - the context of execution; may be null, then it will be ignored.
See Also:
Array.freeResources(ArrayContext), Array.flushResources(ArrayContext), Array.flushResources(ArrayContext, boolean)

flushResources

public void flushResources(ArrayContext context,
                           boolean forcePhysicalWriting)
This implementation calls flushResources(context, 0, length(), forcePhysicalWriting).

Specified by:
flushResources in interface Array
Overrides:
flushResources in class AbstractArray
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:
Array.loadResources(ArrayContext), Array.flushResources(ArrayContext), Array.freeResources(ArrayContext, boolean)

freeResources

public void freeResources(ArrayContext context,
                          boolean forcePhysicalWriting)
This implementation calls freeResources(context, 0, length()), forcePhysicalWriting).

Specified by:
freeResources in interface Array
Overrides:
freeResources in class AbstractArray
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:
Array.loadResources(ArrayContext context), Array.flushResources(ArrayContext context, boolean forcePhysicalWriting), Array.freeResources(ArrayContext), Arrays.freeAllResources()

loadResources

protected void loadResources(ArrayContext context,
                             long fromIndex,
                             long toIndex)
This method implements all actions that should be performed by subArray(fromIndex, toIndex).loadResources(context) call. This default implementation calls loadResources(c) (where c is a necessary part of 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:
java.lang.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 subArray(fromIndex, toIndex).flushResources(context, forcePhysicalWriting) call. This default implementation calls flushResources(c, forcePhysicalWriting) (where c is a necessary part of 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 (alike AbstractArray.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:
java.lang.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 subArray(fromIndex, toIndex).freeResources(context, forcePhysicalWriting) call. This default implementation calls freeResources(c, forcePhysicalWriting) (where c is a necessary part of 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 (alike AbstractArray.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:
java.lang.IndexOutOfBoundsException - for illegal fromIndex and toIndex (fromIndex < 0 || toIndex > length() || fromIndex > toIndex).

toString

public java.lang.String toString()
Description copied from interface: Array
Returns 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 use Arrays.toString(CharArray) method.

Specified by:
toString in interface Array
Specified by:
toString in class AbstractArray
Returns:
a brief string description of this object.

minPossibleValue

public double minPossibleValue(double valueForFloatingPoint)
Description copied from interface: PArray
Returns 0 for BitArray, ByteArray, CharArray and ShortArray, Integer.MIN_VALUE for IntArray, Long.MIN_VALUE for LongArray, valueForFloatingPoint for FloatArray and DoubleArray. For fixed-point arrays it 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 to minPossibleValue(thisArray.getClass(), valueForFloatingPoint).

Specified by:
minPossibleValue in interface PArray
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:
PFixedArray.minPossibleValue()

maxPossibleValue

public double maxPossibleValue(double valueForFloatingPoint)
Description copied from interface: PArray
Returns 1 for BitArray, 0xFF for ByteArray, 0xFFFF for CharArray and ShortArray, Integer.MAX_VALUE for IntArray, Long.MAX_VALUE for LongArray, valueForFloatingPoint for FloatArray and DoubleArray. For fixed-point arrays it 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 to maxPossibleValue(thisArray.getClass(), valueForFloatingPoint).

Specified by:
maxPossibleValue in interface PArray
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:
PFixedArray.maxPossibleValue()