Class SimpleMemoryModel
- All Implemented Interfaces:
MemoryModel
The simplest memory model, based on usual Java arrays.
It means that AlgART array of elements of some type
contains an underlying Java array type[],
and any access to AlgART array elements is translated
to corresponding access to the underlying Java array.
The only exception is bit arrays
,
where the bits are packed into long[] Java array,
as specified in PackedBitArrays
class.
This memory model supports all possible element types. The maximal theoretical limit for length and capacity of AlgART arrays, supported by this memory model, is 237-64 for bit arrays and 231-1 for all other element types. The real limit is essentially less, usually 2 GB in 64-bit JVM or ~1.0-1.5 GB in 32-bit JVM.
This memory model may be not effective enough for very large arrays of
non-primitive elements (inheritors of Object class):
it stores them as array of pointers, alike standard ArrayList.
For effective storing arrays of objects, we recommend using
the combined memory model
.
All arrays created by this memory model, besides bit arrays and immutable views
of the arrays, implement DirectAccessible
interface,
DirectAccessible.hasJavaArray()
returns true for such arrays,
and DirectAccessible.javaArrayOffset()
returns 0 for them.
Moreover, if this array is created as unresizable using
newUnresizableArray(Class, long)
method or some equivalent way,
including newUnresizableXxxArray or newMatrix methods,
then you can be sure that its length (returned by Array.length()
and
DirectAccessible.javaArrayLength()
methods) is equal to the actual length
of the Java array, returned by DirectAccessible.javaArray()
method;
Arrays.isJavaArrayWrapper(Array)
returns true for such arrays.
All arrays, created by this memory model, have empty implementation of
Array.loadResources(ArrayContext)
,
Array.flushResources(ArrayContext)
, Array.flushResources(ArrayContext, boolean)
and
Array.freeResources(ArrayContext)
methods:
these methods do nothing.
In the arrays of objects (non-primitive) created by this memory model:
ObjectInPlaceArray
,UpdatableObjectInPlaceArray
,MutableObjectInPlaceArray
interfaces are never implemented;UpdatableArray.copy(Array)
,UpdatableArray.copy(long, long)
,UpdatableArray.copy(long, long, long)
,UpdatableArray.swap(UpdatableArray)
,UpdatableArray.swap(long, long)
,UpdatableArray.swap(long, long, long)
methods copies only references to objects, but do not perform deep cloning;Array.hashCode()
,Array.equals(Object)
methods are based on implementation of hashCode and equals method in the class of elements (Array.elementType()
).
This class is immutable and thread-safe:
there are no ways to modify settings of its instance returned by getInstance()
method.
Moreover, it is a singleton: getInstance()
always returns the same object.
- Author:
- Daniel Alievsky
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if this memory model can create arrays with all element types.boolean
Returns true if this memory model can create arrays with all primitive element types: boolean, char, byte, short, int, long, float, double.static Matrix<UpdatablePArray>
Equivalent toMatrices.matrix
(asUpdatablePArray
(array), dim).static UpdatableArray
asUpdatableArray
(Object array) Returns a wrapper: an unresizable AlgART array backed by the specified Java array, excluding a case of boolean[] array.static UpdatableBitArray
asUpdatableBitArray
(long[] packedBitArray, long length) Returns an unresizable AlgART bit array backed by the specified long[]>array according the packing rules, describing inPackedBitArrays
class.static UpdatableByteArray
asUpdatableByteArray
(byte[] array) Equivalent to (UpdatableByteArray)asUpdatableArray
((Object)array).static UpdatableCharArray
asUpdatableCharArray
(char[] array) Equivalent to (UpdatableCharArray)asUpdatableArray
((Object)array).static UpdatableDoubleArray
asUpdatableDoubleArray
(double[] array) Equivalent to (UpdatableDoubleArray)asUpdatableArray
((Object)array).static UpdatableFloatArray
asUpdatableFloatArray
(float[] array) Equivalent to (UpdatableFloatArray)asUpdatableArray
((Object)array).static UpdatableIntArray
asUpdatableIntArray
(int[] array) Equivalent to (UpdatableIntArray)asUpdatableArray
((Object)array).static UpdatableLongArray
asUpdatableLongArray
(long[] array) Equivalent to (UpdatableLongArray)asUpdatableArray
((Object)array).static <E> UpdatableObjectArray<E>
asUpdatableObjectArray
(E[] array) Equivalent to (UpdatableObjectArray) .asUpdatableArray
((Object)array)static UpdatablePArray
asUpdatablePArray
(Object array) Analog ofasUpdatableArray(Object)
with the only difference, that this method does not work with Java array of objects.static UpdatableShortArray
asUpdatableShortArray
(short[] array) Equivalent to (UpdatableShortArray)asUpdatableArray
((Object)array).static SimpleMemoryModel
Returns an instance of this memory model.boolean
isCreatedBy
(Array array) Returns true if the passed array was created by this (or identical) memory model.boolean
isElementTypeSupported
(Class<?> elementType) Returns true if this memory model can create arrays with this element type.static boolean
isSimpleArray
(Array array) Returns true if the passed instance is an array created by this memory model.long
maxSupportedLength
(Class<?> elementType) This implementation returns Integer.MAX_VALUE == 231-1 for all element types besides boolean.class, or some large value (depending on implementation) for boolean.class.Allocates a zero-filled resizable array with the specified element type and initial length.newEmptyArray
(Class<?> elementType) Allocates an empty resizable array with the specified element type and a little initial capacity.newEmptyArray
(Class<?> elementType, long initialCapacity) Allocates an empty resizable array with the specified element type and initial capacity.newUnresizableArray
(Class<?> elementType, long length) Allocates a zero-filled unresizable array with the specified element type and length.toString()
Returns a brief string description of this memory model.valueOf
(boolean[] array) Equivalent to (UpdatableBitArray)valueOf
((Object)array).valueOf
(boolean[] array, int offset, int count) Equivalent to (UpdatableBitArray)valueOf
((Object)array, offset, count).valueOf
(byte[] array) Equivalent to (UpdatableByteArray)valueOf
((Object)array).valueOf
(byte[] array, int offset, int count) Equivalent to (UpdatableByteArray)valueOf
((Object)array, offset, count).valueOf
(char[] array) Equivalent to (UpdatableCharArray)valueOf
((Object)array).valueOf
(char[] array, int offset, int count) Equivalent to (UpdatableCharArray)valueOf
((Object)array, offset, count).valueOf
(double[] array) Equivalent to (UpdatableDoubleArray)valueOf
((Object)array).valueOf
(double[] array, int offset, int count) Equivalent to (UpdatableDoubleArray)valueOf
((Object)array, offset, count).valueOf
(float[] array) Equivalent to (UpdatableFloatArray)valueOf
((Object)array).valueOf
(float[] array, int offset, int count) Equivalent to (UpdatableFloatArray)valueOf
((Object)array, offset, count).valueOf
(int[] array) Equivalent to (UpdatableIntArray)valueOf
((Object)array).valueOf
(int[] array, int offset, int count) Equivalent to (UpdatableIntArray)valueOf
((Object)array, offset, count).valueOf
(long[] array) Equivalent to (UpdatableLongArray)valueOf
((Object)array).valueOf
(long[] array, int offset, int count) Equivalent to (UpdatableLongArray)valueOf
((Object)array, offset, count).valueOf
(short[] array) Equivalent to (UpdatableShortArray)valueOf
((Object)array).valueOf
(short[] array, int offset, int count) Equivalent to (UpdatableShortArray)valueOf
((Object)array, offset, count).Allocates an unresizable AlgART array containing all elements of the specified Java array: array[0], array[1], ..., array[array.length - 1].Allocates an unresizable AlgART array containing count elements of the specified Java array: array[offset], array[offset + 1], ..., array[offset + count - 1].Methods inherited from class net.algart.arrays.AbstractMemoryModel
newArray, newBitArray, newBitMatrix, newByteArray, newByteMatrix, newCharArray, newCharMatrix, newDoubleArray, newDoubleMatrix, newEmptyBitArray, newEmptyBitArray, newEmptyByteArray, newEmptyByteArray, newEmptyCharArray, newEmptyCharArray, newEmptyDoubleArray, newEmptyDoubleArray, newEmptyFloatArray, newEmptyFloatArray, newEmptyIntArray, newEmptyIntArray, newEmptyLongArray, newEmptyLongArray, newEmptyObjectArray, newEmptyObjectArray, newEmptyShortArray, newEmptyShortArray, newFloatArray, newFloatMatrix, newIntArray, newIntMatrix, newLazyCopy, newLazyCopy, newLongArray, newLongMatrix, newMatrix, newMatrix, newMatrix, newObjectArray, newObjectMatrix, newShortArray, newShortMatrix, newStructuredMatrix, newUnresizableArray, newUnresizableBitArray, newUnresizableByteArray, newUnresizableCharArray, newUnresizableDoubleArray, newUnresizableFloatArray, newUnresizableIntArray, newUnresizableLazyCopy, newUnresizableLongArray, newUnresizableObjectArray, newUnresizableShortArray, valueOf, valueOf
-
Method Details
-
getInstance
Returns an instance of this memory model. This method always returns the same object.- Returns:
- an instance of this memory model.
- See Also:
-
newEmptyArray
Description copied from interface:MemoryModel
Allocates an empty resizable array with the specified element type and a little initial capacity. It is equivalent tonewEmptyArray(elementType, n)
, where n is some little value.Example of usage:
MutableFloatArray a = (MutableFloatArray)memoryModel.newEmptyArray(float.class);
- Specified by:
newEmptyArray
in interfaceMemoryModel
- Specified by:
newEmptyArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.- Returns:
- created AlgART array.
- See Also:
-
newEmptyArray
Description copied from interface:MemoryModel
Allocates an empty resizable array with the specified element type and initial capacity.The element type can be either usual object class (as String.class), or one of the primitive types: boolean.class, byte.class, short.class, int.class, long.class, float.class, double.class, char.class. The element type cannot be void.class.
In a case of primitive types, the created array will implement the corresponding interface
BitArray
,ByteArray
,ShortArray
,IntArray
,LongArray
,FloatArray
,DoubleArray
orCharArray
. In this case, the created array (unlike standard ArrayList) will occupy the same amount of memory as the Java array boolean[initialCapacity], byte[initialCapacity], etc.In a case of non-primitive types (Object inheritors), the created array will implement the
MutableObjectArray
interface.Some element type may be not supported by this memory model. For example, some memory models may support only primitive types, or only one concrete type. In such a case,
UnsupportedElementTypeException
will be thrown.Some too large array capacities may be not supported by this memory model. For example,
SimpleMemoryModel
does not support arrays larger than 0x7FFFFFFF (Integer.MAX_VALUE) elements.Example of usage:
MutableFloatArray a = (MutableFloatArray)memoryModel.newEmptyArray(float.class, 10000);
- Specified by:
newEmptyArray
in interfaceMemoryModel
- Specified by:
newEmptyArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.initialCapacity
- the initial capacity of the array.- Returns:
- created AlgART array.
- See Also:
-
newArray
Description copied from interface:MemoryModel
Allocates a zero-filled resizable array with the specified element type and initial length. The capacity of new array will be equal to its length.This method is equivalent to the following call:
newEmptyArray(elementType, initialLength)
.length(initialLength)
.trim()
.- Specified by:
newArray
in interfaceMemoryModel
- Specified by:
newArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.initialLength
- the initial length and capacity of the array.- Returns:
- created AlgART array.
- See Also:
-
newUnresizableArray
Description copied from interface:MemoryModel
Allocates a zero-filled unresizable array with the specified element type and length. The capacity of new array will be equal to its length.The analogous result may be obtained the following call:
newArray(elementType, length)
.asUnresizable()
. However, we don't recommend to use such code. If you are sure that you will not need to change the array length, please always use this method (ornewUnresizableBitArray
,newUnresizableBteArray
, etc.). In some memory models, creating resizable array with the given length may require much more resources that creating unresizable one. For example, in thelarge memory model
every resizable array is stored in the file consisting of integer number of blocks perDataFileModel.recommendedBankSize(true)
bytes.- Specified by:
newUnresizableArray
in interfaceMemoryModel
- Specified by:
newUnresizableArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.length
- the length and capacity of the array.- Returns:
- created unresizable AlgART array.
- See Also:
-
valueOf
Description copied from interface:MemoryModel
Allocates an unresizable AlgART array containing count elements of the specified Java array: array[offset], array[offset + 1], ..., array[offset + count - 1].The returned AlgART array will be "safe" in the sense that no references to the passed Java array are maintained by it. In other words, this method must always allocate a new AlgART array.
This method is equivalent to the following expression:
newUnresizableArray
(elementType, count).setData
(0, array, offset, count), where elementType is the type of array elements (array.getClass().getComponentType()).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Allocates an unresizable AlgART array containing all elements of the specified Java array: array[0], array[1], ..., array[array.length - 1].The returned AlgART array will be "safe" in the sense that no references to the passed Java array are maintained by it. In other words, this method must always allocate a new array.
This method is equivalent to the following expression:
newUnresizableArray
(elementType, len).setData
(0, array), where elementType is the type of array elements (array.getClass().getComponentType()) and len is the length of the passed Java array.- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableBitArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableBitArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableCharArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableCharArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableByteArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableByteArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableShortArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableShortArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableIntArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableIntArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableLongArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableLongArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableFloatArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableFloatArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableDoubleArray)valueOf
((Object)array, offset, count).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.offset
- starting position in the source Java array.count
- the length of returned AlgART array.- Returns:
- created unresizable AlgART array.
-
valueOf
Description copied from interface:MemoryModel
Equivalent to (UpdatableDoubleArray)valueOf
((Object)array).- Specified by:
valueOf
in interfaceMemoryModel
- Overrides:
valueOf
in classAbstractMemoryModel
- Parameters:
array
- the source Java array with elements of constructed AlgART array.- Returns:
- created unresizable AlgART array.
-
isElementTypeSupported
Description copied from interface:MemoryModel
Returns true if this memory model can create arrays with this element type. If it does not support it, creation methods of this memory model will throwUnsupportedElementTypeException
. The result is not defined for void.class.- Specified by:
isElementTypeSupported
in interfaceMemoryModel
- Specified by:
isElementTypeSupported
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.- Returns:
- true if this memory model supports this element type.
-
areAllPrimitiveElementTypesSupported
public boolean areAllPrimitiveElementTypesSupported()Description copied from interface:MemoryModel
Returns true if this memory model can create arrays with all primitive element types: boolean, char, byte, short, int, long, float, double.- Specified by:
areAllPrimitiveElementTypesSupported
in interfaceMemoryModel
- Specified by:
areAllPrimitiveElementTypesSupported
in classAbstractMemoryModel
- Returns:
- true if this memory model supports all primitive element types.
- See Also:
-
areAllElementTypesSupported
public boolean areAllElementTypesSupported()Description copied from interface:MemoryModel
Returns true if this memory model can create arrays with all element types. This package offers only one such memory model:SimpleMemoryModel
.- Specified by:
areAllElementTypesSupported
in interfaceMemoryModel
- Specified by:
areAllElementTypesSupported
in classAbstractMemoryModel
- Returns:
- true if this memory model supports element types.
- See Also:
-
maxSupportedLength
This implementation returns Integer.MAX_VALUE == 231-1 for all element types besides boolean.class, or some large value (depending on implementation) for boolean.class.In current implementation, returns 237-64 for boolean.class, because bits are stored in long values.
- Specified by:
maxSupportedLength
in interfaceMemoryModel
- Specified by:
maxSupportedLength
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.- Returns:
- maximal possible length of arrays supported by this memory model.
- Throws:
NullPointerException
- if elementType is null.
-
isCreatedBy
Description copied from interface:MemoryModel
Returns true if the passed array was created by this (or identical) memory model.For
SimpleMemoryModel
andBufferMemoryModel
, "identical" means the same memory model.For
LargeMemoryModel
, "identical" means that the memory model is also large and was created with the same instance of thedata file factory
.For
CombinedMemoryModel
, "identical" means that the memory model is also combined and was created with the same instance of thecombiner
.Returns false if the passed argument is null.
- Specified by:
isCreatedBy
in interfaceMemoryModel
- Specified by:
isCreatedBy
in classAbstractMemoryModel
- Parameters:
array
- the AlgART array (may be null, than the method returns false).- Returns:
- true if the passed array was created by this memory model.
-
isSimpleArray
Returns true if the passed instance is an array created by this memory model. Returns false if the passed array is null or an AlgART array created by another memory model.As this memory model is a singleton, this method is equivalent to
isCreatedBy(Array)
.- Parameters:
array
- the checked array.- Returns:
- true if this array is created by the simple memory model.
-
toString
Returns a brief string description of this memory model.The result of this method may depend on implementation.
-
asUpdatableArray
Returns a wrapper: an unresizable AlgART array backed by the specified Java array, excluding a case of boolean[] array. For boolean elements (BitArray
) please use the methodasUpdatableBitArray(long[], long)
.The result AlgART array contains all elements the passed Java array: array[0], array[1], ..., array[array.length - 1], and changes in the returned array "write through" to array argument. The length and capacity of the returned array are equal to array.length.
For arrays, created by this method,
Arrays.isJavaArrayWrapper(Array)
method returns true.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.IllegalArgumentException
- if array argument is not an array or boolean[] array.
-
asUpdatablePArray
Analog ofasUpdatableArray(Object)
with the only difference, that this method does not work with Java array of objects.This method has a brief alias:
PArray.as(Object)
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.IllegalArgumentException
- if array argument is not an array, or boolean[] array, or Objects[] array.
-
asUpdatableBitArray
Returns an unresizable AlgART bit array backed by the specified long[]>array according the packing rules, describing inPackedBitArrays
class. Changes in the returned array "write through" to array argument. The length and capacity of the returned array are equal to the specified length argument.This method has a brief alias:
BitArray.as(long[], long)
.- Parameters:
packedBitArray
- the source long[]> array.length
- the length of the returned bit array.- Returns:
- an unresizable AlgART bit array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.IllegalArgumentException
- if length<0 or if the passed array is too short to store length bits (i.e. if array.length < (length+63)/64).
-
asUpdatableCharArray
Equivalent to (UpdatableCharArray)asUpdatableArray
((Object)array).This method has a brief alias:
CharArray.as(char[])
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asUpdatableByteArray
Equivalent to (UpdatableByteArray)asUpdatableArray
((Object)array).This method has a brief alias:
ByteArray.as(byte[])
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asUpdatableShortArray
Equivalent to (UpdatableShortArray)asUpdatableArray
((Object)array).This method has a brief alias:
ShortArray.as(short[])
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asUpdatableIntArray
Equivalent to (UpdatableIntArray)asUpdatableArray
((Object)array).This method has a brief alias:
IntArray.as(int[])
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asUpdatableLongArray
Equivalent to (UpdatableLongArray)asUpdatableArray
((Object)array).This method has a brief alias:
LongArray.as(long[])
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asUpdatableFloatArray
Equivalent to (UpdatableFloatArray)asUpdatableArray
((Object)array).This method has a brief alias:
FloatArray.as(float[])
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asUpdatableDoubleArray
Equivalent to (UpdatableDoubleArray)asUpdatableArray
((Object)array).This method has a brief alias:
DoubleArray.as(double[])
.- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asUpdatableObjectArray
Equivalent to (UpdatableObjectArray) .asUpdatableArray
((Object)array)- Parameters:
array
- the source Java array.- Returns:
- an unresizable AlgART array backed by the specified Java array.
- Throws:
NullPointerException
- if array argument is null.
-
asMatrix
Equivalent toMatrices.matrix
(asUpdatablePArray
(array), dim).Note that this method cannot be used with Object[] array. If you still need to return a matrix of objects, you may use Matrices.matrix method together with
asUpdatableArray(Object)
.This method has a brief alias:
Matrix.as(Object, long...)
.- Parameters:
array
- the source Java array.dim
- the matrix dimensions.- Returns:
- a matrix backed by the specified Java array with the specified dimensions.
- Throws:
NullPointerException
- if array or dim argument is null.IllegalArgumentException
- if array argument is not an array, or boolean[] array, or array of objects, or if the number of dimensions is 0 (empty dim Java array), or if some of the dimensions are negative.SizeMismatchException
- if the product of all dimensions is not equal to the array length.TooLargeArrayException
- if the product of all dimensions is greater than Long.MAX_VALUE.
-