Class AbstractLongArray
- All Implemented Interfaces:
Cloneable
,Array
,LongArray
,PArray
,PFixedArray
,PIntegerArray
,PNumberArray
- Direct Known Subclasses:
AbstractUpdatableLongArray
Implementation of almost all basic functions of LongArray
interface.
The only LongArray.getLong(long)
method is not defined in this class;
all other methods are implemented via calls of LongArray.getLong(long)
.
- Author:
- Daniel Alievsky
-
Field Summary
Fields inherited from class net.algart.arrays.AbstractArray
capacity, length, underlyingArrays
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractLongArray
(long initialCapacityAndLength, boolean underlyingArraysAreParallel, Array... underlyingArrays) Equivalent to the constructorAbstractLongArray(long, long, boolean, Array...)
, where both initialCapacity and initialLength arguments are equal to initialCapacityAndLength.protected
AbstractLongArray
(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.long
Return 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.void
This implementation does nothing.Class<?>
Returns the type of array elements.void
flushResources
(ArrayContext context, boolean forcePhysicalWriting) This implementation callsflushResources(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 call.subArray
(fromIndex, toIndex).flushResources(context, forcePhysicalWriting)
void
freeResources
(ArrayContext context, boolean forcePhysicalWriting) This implementation callsfreeResources(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 call.subArray
(fromIndex, toIndex).freeResources(context, forcePhysicalWriting)
void
This implementation callsgetData(long, Object, int, int)
with corresponding arguments.void
This implementation is based on a loop of calls ofgetLong(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.getElement
(long index) This implementation returns getLong(index).int
getInt
(long index) Returns the element #index, truncated to the range Integer.MIN_VALUE..Integer.MAX_VALUE: min(max(value, Integer.MIN_VALUE), Integer.MAX_VALUE).abstract long
getLong
(long index) Returns the element #index.long
indexOf
(long lowIndex, long highIndex, double value) This implementation returns value==(long)value ?indexOf
(lowIndex, highIndex, (long)value) : -1.long
indexOf
(long lowIndex, long highIndex, long value) This implementation is based on a loop of calls ofgetLong(long)
method from index max(lowIndex,0) until index min(AbstractArray.length()
,highIndex)-1.boolean
This implementation returns false.boolean
This implementation returns true.boolean
This implementation returns true.long[]
ja()
This implementation performs the following code:long
lastIndexOf
(long lowIndex, long highIndex, double value) This implementation returns value==(long)value ?lastIndexOf
(lowIndex, highIndex, (long)value) : -1.long
lastIndexOf
(long lowIndex, long highIndex, long value) This implementation is based on a loop of calls ofgetLong(long)
method from index min(AbstractArray.length()
,highIndex)-1 back until index max(lowIndex,0).void
loadResources
(ArrayContext context) This implementation callsloadResources(context, 0, length())
.protected void
loadResources
(ArrayContext context, long fromIndex, long toIndex) This method implements all actions that should be performed by call.subArray
(fromIndex, toIndex).loadResources
(context)long
double
maxPossibleValue
(double valueForFloatingPoint) Returns 1 forBitArray
, 0xFF forByteArray
, 0xFFFF forCharArray
andShortArray
, Integer.MAX_VALUE forIntArray
, Long.MAX_VALUE forLongArray
, valueForFloatingPoint forFloatArray
andDoubleArray
.long
double
minPossibleValue
(double valueForFloatingPoint) Returns 0 forBitArray
,ByteArray
,CharArray
andShortArray
, Integer.MIN_VALUE forIntArray
, Long.MIN_VALUE forLongArray
, valueForFloatingPoint forFloatArray
andDoubleArray
.mutableClone
(MemoryModel memoryModel) Class<? extends MutableLongArray>
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 ofAbstractLongArray
with the same memory model, underlying arrays and underlyingArraysAreParallel flag, that were passed to the constructor of this instance, and with overridden methodsgetLong(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.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 UpdatableLongArray>
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.Array
byteOrder, capacity, equals, flushResources, freeResources, hashCode, isEmpty, isLazy, isNew, isNewReadOnlyView, length, length32, newJavaArray, shallowClone, subArr
-
Constructor Details
-
AbstractLongArray
protected AbstractLongArray(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 correspondingsubarrays
of 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
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 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
-
AbstractLongArray
protected AbstractLongArray(long initialCapacityAndLength, boolean underlyingArraysAreParallel, Array... underlyingArrays) Equivalent to the constructorAbstractLongArray(long, long, boolean, Array...)
, where both initialCapacity and initialLength arguments are equal to initialCapacityAndLength.- Parameters:
initialCapacityAndLength
- initial capacity and length of the array.underlyingArraysAreParallel
- seeAbstractLongArray(long, long, boolean, Array...)
.underlyingArrays
- seeAbstractLongArray(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:Array
Returns 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:
elementType
in interfaceArray
- Specified by:
elementType
in classAbstractArray
- Returns:
- the type of array elements.
- See Also:
- boolean.class for
-
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: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:
type
in interfaceArray
- Specified by:
type
in interfaceLongArray
- Specified by:
type
in interfacePArray
- Specified by:
type
in interfacePIntegerArray
- Specified by:
type
in interfacePNumberArray
- Specified by:
type
in classAbstractArray
- Returns:
- canonical AlgART type of this array.
-
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: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:
updatableType
in interfaceArray
- Specified by:
updatableType
in interfaceLongArray
- Specified by:
updatableType
in interfacePArray
- Specified by:
updatableType
in interfacePIntegerArray
- Specified by:
updatableType
in interfacePNumberArray
- Specified by:
updatableType
in classAbstractArray
- Returns:
- canonical AlgART type of an updatable array of the same kind.
-
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: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:
mutableType
in interfaceArray
- Specified by:
mutableType
in interfaceLongArray
- Specified by:
mutableType
in interfacePArray
- Specified by:
mutableType
in interfacePIntegerArray
- Specified by:
mutableType
in interfacePNumberArray
- Specified by:
mutableType
in classAbstractArray
- Returns:
- canonical AlgART type of a resizable array of the same kind.
-
getData
This implementation is based on a loop of calls ofgetLong(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 interfaceArray
- Specified by:
getData
in 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:
getData
in interfaceArray
- Specified by:
getData
in 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 getLong(index).- Specified by:
getElement
in interfaceArray
- Specified by:
getElement
in 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 ofAbstractLongArray
with the same memory model, underlying arrays and underlyingArraysAreParallel flag, that were passed to the constructor of this instance, and with overridden methodsgetLong(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:
subArray
in interfaceArray
- Specified by:
subArray
in 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:AbstractArray
This 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 implementsDirectAccessible
interface and itshasJavaArray()
method returns true, or it is a bit array created by thesimple memory model
. -
buffer
Description copied from class:AbstractArray
This implementation returnsbuffer(mode, someCapacity)
, where mode is the argument of this method and someCapacity is the result ofdefaultBufferCapacity(thisArray)
method. -
buffer
Description copied from class:AbstractArray
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
Description copied from class:AbstractArray
This implementation returnsbuffer(suitableMode)
, where suitableMode is this instanceof UpdatableArray ? DataBuffer.AccessMode.READ_WRITE : DataBuffer.AccessMode.READ. -
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 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_BIT
constant), - 16 for
CharArray
(the value ofArrays.BITS_PER_CHAR
constant), - 8 for
ByteArray
(the value ofArrays.BITS_PER_BYTE
constant), - 16 for
ShortArray
(the value ofArrays.BITS_PER_SHORT
constant), - 32 for
IntArray
(the value ofArrays.BITS_PER_INT
constant), - 64 for
LongArray
(the value ofArrays.BITS_PER_LONG
constant), - 32 for
FloatArray
(the value ofArrays.BITS_PER_FLOAT
constant), - 64 for
DoubleArray
(the value ofArrays.BITS_PER_DOUBLE
constant).
(-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 model
andlarge 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 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: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 the case of very large long elements. -
indexOf
public long indexOf(long lowIndex, long highIndex, double value) This implementation returns value==(long)value ?indexOf
(lowIndex, highIndex, (long)value) : -1.- Specified by:
indexOf
in 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==(long)value ?lastIndexOf
(lowIndex, highIndex, (long)value) : -1.- Specified by:
lastIndexOf
in 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.
-
getInt
public int getInt(long index) Description copied from interface:LongArray
Returns the element #index, truncated to the range Integer.MIN_VALUE..Integer.MAX_VALUE: min(max(value, Integer.MIN_VALUE), Integer.MAX_VALUE).Note that this method is already declared in
PFixedArray
. It is redeclared here only for documentation and code search purposes.- Specified by:
getInt
in interfaceLongArray
- Specified by:
getInt
in interfacePFixedArray
- Parameters:
index
- index of element to get.- Returns:
- the element at the specified position in this array.
- See Also:
-
getLong
public abstract long getLong(long index) Description copied from interface:LongArray
Returns the element #index.- Specified by:
getLong
in interfaceLongArray
- Specified by:
getLong
in interfacePFixedArray
- Parameters:
index
- index of element to get.- Returns:
- the element at the specified position in this array.
- See Also:
-
indexOf
public long indexOf(long lowIndex, long highIndex, long value) This implementation is based on a loop of calls ofgetLong(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 interfaceLongArray
- Specified by:
indexOf
in interfacePFixedArray
- 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, long value) This implementation is based on a loop of calls ofgetLong(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 interfaceLongArray
- Specified by:
lastIndexOf
in interfacePFixedArray
- 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 interfaceArray
- Specified by:
isImmutable
in 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:
isUnresizable
in interfaceArray
- Specified by:
isUnresizable
in classAbstractArray
- Returns:
- true if this instance is unresizable.
- See Also:
-
checkUnallowedMutation
This implementation does nothing.- Specified by:
checkUnallowedMutation
in interfaceArray
- Specified by:
checkUnallowedMutation
in classAbstractArray
- Throws:
UnallowedMutationError
- never in this implementation.- See Also:
-
asTrustedImmutable
This implementation callsasImmutable()
and returns its result.- Specified by:
asTrustedImmutable
in interfaceArray
- Specified by:
asTrustedImmutable
in interfaceLongArray
- Specified by:
asTrustedImmutable
in interfacePArray
- Specified by:
asTrustedImmutable
in interfacePFixedArray
- Specified by:
asTrustedImmutable
in interfacePIntegerArray
- Specified by:
asTrustedImmutable
in 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:
asCopyOnNextWrite
in interfaceArray
- Specified by:
asCopyOnNextWrite
in 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:
isCopyOnNextWrite
in interfaceArray
- Specified by:
isCopyOnNextWrite
in 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:
asImmutable
in interfaceArray
- Specified by:
asImmutable
in interfaceLongArray
- Specified by:
asImmutable
in interfacePArray
- Specified by:
asImmutable
in interfacePFixedArray
- Specified by:
asImmutable
in interfacePIntegerArray
- Specified by:
asImmutable
in 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:
mutableClone
in interfaceArray
- Specified by:
mutableClone
in interfaceLongArray
- Specified by:
mutableClone
in interfacePArray
- Specified by:
mutableClone
in interfacePFixedArray
- Specified by:
mutableClone
in interfacePIntegerArray
- Overrides:
mutableClone
in 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:AbstractArray
This implementation performs the following: memoryModel.newUnresizableArray
(thisArray).copy
(thisArray).- Specified by:
updatableClone
in interfaceArray
- Specified by:
updatableClone
in interfaceLongArray
- Specified by:
updatableClone
in interfacePArray
- Specified by:
updatableClone
in interfacePFixedArray
- Specified by:
updatableClone
in interfacePIntegerArray
- Overrides:
updatableClone
in 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 long[] ja()Description copied from class:AbstractArray
This 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);
-
loadResources
This implementation callsloadResources(context, 0, length())
.- Specified by:
loadResources
in interfaceArray
- Overrides:
loadResources
in 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:
flushResources
in interfaceArray
- Overrides:
flushResources
in 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:
freeResources
in interfaceArray
- Overrides:
freeResources
in 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 necessarypart
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:
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 necessarypart
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 (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 necessarypart
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 (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: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 useArrays.toString(CharArray)
method.- Specified by:
toString
in interfaceArray
- Specified by:
toString
in classAbstractArray
- Returns:
- a brief string description of this object.
-
minPossibleValue
public double minPossibleValue(double valueForFloatingPoint) Description copied from interface:PArray
Returns 0 forBitArray
,ByteArray
,CharArray
andShortArray
, Integer.MIN_VALUE forIntArray
, Long.MIN_VALUE forLongArray
, valueForFloatingPoint forFloatArray
andDoubleArray
. Forfixed-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 tominPossibleValue
(thisArray.getClass(), valueForFloatingPoint).- Specified by:
minPossibleValue
in 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:PArray
Returns 1 forBitArray
, 0xFF forByteArray
, 0xFFFF forCharArray
andShortArray
, Integer.MAX_VALUE forIntArray
, Long.MAX_VALUE forLongArray
, valueForFloatingPoint forFloatArray
andDoubleArray
. Forfixed-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 tomaxPossibleValue
(thisArray.getClass(), valueForFloatingPoint).- Specified by:
maxPossibleValue
in 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:
-
minPossibleValue
public long minPossibleValue()Description copied from interface:PFixedArray
Returns 0 forBitArray
,ByteArray
,CharArray
andShortArray
, Integer.MIN_VALUE forIntArray
, Long.MIN_VALUE forLongArray
. 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 tominPossibleIntegerValue
(thisArray.getClass()).- Specified by:
minPossibleValue
in interfacePFixedArray
- Returns:
- the minimal possible value, that can stored in elements of this array.
- See Also:
-
maxPossibleValue
public long maxPossibleValue()Description copied from interface:PFixedArray
Returns 1 forBitArray
, 0xFF forByteArray
, 0xFFFF forCharArray
andShortArray
, Integer.MAX_VALUE forIntArray
, Long.MAX_VALUE forLongArray
. valueForFloatingPoint forFloatArray
andDoubleArray
. 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 tomaxPossibleIntegerValue
(thisArray.getClass()).- Specified by:
maxPossibleValue
in interfacePFixedArray
- Returns:
- the maximal possible value, that can stored in elements of this array.
- See Also:
-