AlgART Home

net.algart.arrays
Interface MemoryModel

All Known Implementing Classes:
AbstractMemoryModel, BufferMemoryModel, CombinedMemoryModel, LargeMemoryModel, SignalMemoryModel, SimpleMemoryModel

public interface MemoryModel

Virtual memory model: implementations of this abstract factory is the main way of creating new AlgART arrays.

Virtual memory model is an abstraction describing how the array elements are stored in memory. For example, the simplest memory model is SimpleMemoryModel, that use Java arrays for storing array elements (alike java.util.ArrayList). Another example is LargeMemoryModel: memory model based on direct byte buffers created via java.nio.ByteBuffer.allocateDirect method or via mapping disk files.

The arrays, created with help of different memory models, implement identical interfaces and usually look absolutely identical for an application, but may work with differente performance. For example, if you need an array of simple object elements (as "circles" or "points"), you may choose CombinedMemoryModel memory model to save memory and provide quick memory allocation, or SimpleMemoryModel to provide maximal performance while accessing array elements.

Some arrays may have no well-defined memory model, but be created without any factories. The simples example is a constant arrays created by methods Arrays.nByteCopies(long, byte), Arrays.nCharCopies(long, char), etc.

Objects implementing this interface may be not immutable, though all its implementations in this package are immutable. But there is a guarantee that any memory model is thread-safe and can be used simultaneously in several threads. (In other words, if another package implements a custom mutable memory model, it must be internally synchronized.)

AlgART Laboratory 2007-2013

Since:
JDK 1.5
Version:
1.2
Author:
Daniel Alievsky

Method Summary
Modifier and Type Method and Description
 boolean areAllElementTypesSupported()
          Returns true if this memory model can create arrays with all element types.
 boolean areAllPrimitiveElementTypesSupported()
          Returns true if this memory model can create arrays with all primitive element types: boolean, char, byte, short, int, long, float, double.
 boolean isCreatedBy(Array array)
          Returns true if the passed array was created by this (or identical) memory model.
 boolean isElementTypeSupported(java.lang.Class<?> elementType)
          Returns true if this memory model can create arrays with this element type.
 long maxSupportedLength(java.lang.Class<?> elementType)
          Returnes maximal possible length of arrays with the specified element type supported by this memory model.
 MutableArray newArray(Array array)
          Equivalent to newArray(array.elementType(), array.length()).
 MutableArray newArray(java.lang.Class<?> elementType, long initialLength)
          Constructs a zero-filled resizable array with the specified element type and initial length.
 MutableBitArray newBitArray(long initialLength)
          Equivalent to (MutableBitArray)newArray(boolean.class, initialLength).
 Matrix<UpdatableBitArray> newBitMatrix(long... dim)
          Equivalent to newMatrix(UpdatableBitArray.class, boolean.class, dim).
 MutableByteArray newByteArray(long initialLength)
          Equivalent to (MutableByteArray)newArray(byte.class, initialLength).
 Matrix<UpdatableByteArray> newByteMatrix(long... dim)
          Equivalent to newMatrix(UpdatableByteArray.class, byte.class, dim).
 MutableCharArray newCharArray(long initialLength)
          Equivalent to (MutableCharArray)newArray(char.class, initialLength).
 Matrix<UpdatableCharArray> newCharMatrix(long... dim)
          Equivalent to newMatrix(UpdatableCharArray.class, char.class, dim).
 MutableDoubleArray newDoubleArray(long initialLength)
          Equivalent to (MutableDoubleArray)newArray(double.class, initialLength).
 Matrix<UpdatableDoubleArray> newDoubleMatrix(long... dim)
          Equivalent to newMatrix(UpdatableDoubleArray.class, double.class, dim).
 MutableArray newEmptyArray(java.lang.Class<?> elementType)
          Constructs an empty resizable array with the specified element type and a little initial capacity.
 MutableArray newEmptyArray(java.lang.Class<?> elementType, long initialCapacity)
          Constructs an empty resizable array with the specified element type and initial capacity.
 MutableBitArray newEmptyBitArray()
          Equivalent to (MutableBitArray)newEmptyArray(boolean.class).
 MutableBitArray newEmptyBitArray(long initialCapacity)
          Equivalent to (MutableBitArray)newEmptyArray(boolean.class, initialCapacity).
 MutableByteArray newEmptyByteArray()
          Equivalent to (MutableByteArray)newEmptyArray(byte.class).
 MutableByteArray newEmptyByteArray(long initialCapacity)
          Equivalent to (MutableByteArray)newEmptyArray(byte.class, initialCapacity).
 MutableCharArray newEmptyCharArray()
          Equivalent to (MutableCharArray)newEmptyArray(char.class).
 MutableCharArray newEmptyCharArray(long initialCapacity)
          Equivalent to (MutableCharArray)newEmptyArray(char.class, initialCapacity).
 MutableDoubleArray newEmptyDoubleArray()
          Equivalent to (MutableDoubleArray)newEmptyArray(double.class).
 MutableDoubleArray newEmptyDoubleArray(long initialCapacity)
          Equivalent to (MutableDoubleArray)newEmptyArray(double.class, initialCapacity).
 MutableFloatArray newEmptyFloatArray()
          Equivalent to (MutableFloatArray)newEmptyArray(float.class).
 MutableFloatArray newEmptyFloatArray(long initialCapacity)
          Equivalent to (MutableFloatArray)newEmptyArray(float.class, initialCapacity).
 MutableIntArray newEmptyIntArray()
          Equivalent to (MutableIntArray)newEmptyArray(int.class).
 MutableIntArray newEmptyIntArray(long initialCapacity)
          Equivalent to (MutableIntArray)newEmptyArray(int.class, initialCapacity).
 MutableLongArray newEmptyLongArray()
          Equivalent to (MutableLongArray)newEmptyArray(long.class).
 MutableLongArray newEmptyLongArray(long initialCapacity)
          Equivalent to (MutableLongArray)newEmptyArray(long.class, initialCapacity).
<E> MutableObjectArray<E>
newEmptyObjectArray(java.lang.Class<E> elementType)
          Equivalent to (MutableObjectArray<E>)newEmptyArray(elementType).
<E> MutableObjectArray<E>
newEmptyObjectArray(java.lang.Class<E> elementType, long initialCapacity)
          Equivalent to (MutableObjectArray<E>)newEmptyArray(elementType, initialCapacity).
 MutableShortArray newEmptyShortArray()
          Equivalent to (MutableShortArray)newEmptyArray(short.class).
 MutableShortArray newEmptyShortArray(long initialCapacity)
          Equivalent to (MutableShortArray)newEmptyArray(short.class, initialCapacity).
 MutableFloatArray newFloatArray(long initialLength)
          Equivalent to (MutableFloatArray)newArray(float.class, initialLength).
 Matrix<UpdatableFloatArray> newFloatMatrix(long... dim)
          Equivalent to newMatrix(UpdatableFloatArray.class, float.class, dim).
 MutableIntArray newIntArray(long initialLength)
          Equivalent to (MutableIntArray)newArray(int.class, initialLength).
 Matrix<UpdatableIntArray> newIntMatrix(long... dim)
          Equivalent to newMatrix(UpdatableIntArray.class, int.class, dim).
 MutableArray newLazyCopy(Array array)
          Constructs a resizable array with the same content as the passed one, where the actual copying the elements will be deferred as long as possible, maybe, until the first access to elements.
<T extends UpdatableArray>
Matrix<T>
newLazyCopy(java.lang.Class<T> arraySupertype, Matrix<?> matrix)
          Equivalent to matrix.matrix(newUnresizableLazyCopy(matrix.array())).cast(arraySupertype).
 MutableLongArray newLongArray(long initialLength)
          Equivalent to (MutableLongArray)newArray(long.class, initialLength).
 Matrix<UpdatableLongArray> newLongMatrix(long... dim)
          Equivalent to newMatrix(UpdatableLongArray.class, long.class, dim).
<T extends UpdatableArray>
Matrix<T>
newMatrix(java.lang.Class<T> arraySupertype, java.lang.Class<?> elementType, long... dim)
          Constructs a zero-filled matrix with the specified element type and dimensions.
<T extends UpdatableArray>
Matrix<T>
newMatrix(java.lang.Class<T> arraySupertype, Matrix<?> matrix)
          Equivalent to newMatrix(arraySupertype, matrix.elementType(), matrix.dimensions()).
<T extends UpdatableArray>
Matrix<T>
newMatrix(long maxSizeAllocatedInJavaMemory, java.lang.Class<T> arraySupertype, java.lang.Class<?> elementType, long... dim)
          An analog of newMatrix(Class, Class, long...), which automatically uses SignalMemoryModel instead of this memory model if the required matrix size is not greater than maxSizeAllocatedInJavaMemory bytes.
<E> MutableObjectArray<E>
newObjectArray(java.lang.Class<E> elementType, long initialLength)
          Equivalent to (MutableObjectArray<E>)newArray(elementType, initialLength).
<E> Matrix<UpdatableObjectArray<E>>
newObjectMatrix(java.lang.Class<E> elementType, long... dim)
          Equivalent to newMatrix(UpdatableObjectArray.class, elementType, dim).
 MutableShortArray newShortArray(long initialLength)
          Equivalent to (MutableShortArray)newArray(short.class, initialLength).
 Matrix<UpdatableShortArray> newShortMatrix(long... dim)
          Equivalent to newMatrix(UpdatableShortArray.class, short.class, dim).
<T extends UpdatableArray>
Matrix<T>
newStructuredMatrix(java.lang.Class<T> arraySupertype, Matrix<?> matrix)
          Equivalent to newMatrix(arraySupertype, matrix).structureLike(matrix).
 UpdatableArray newUnresizableArray(Array array)
          Equivalent to newUnresizableArray(array.elementType(), array.length()).
 UpdatableArray newUnresizableArray(java.lang.Class<?> elementType, long length)
          Constructs a zero-filled unresizable array with the specified element type and length.
 UpdatableBitArray newUnresizableBitArray(long length)
          Equivalent to (UpdatableBitArray)newUnresizableArray(boolean.class, initialLength).
 UpdatableByteArray newUnresizableByteArray(long length)
          Equivalent to (UpdatableByteArray)newUnresizableArray(byte.class, initialLength).
 UpdatableCharArray newUnresizableCharArray(long length)
          Equivalent to (UpdatableCharArray)newUnresizableArray(char.class, initialLength).
 UpdatableDoubleArray newUnresizableDoubleArray(long length)
          Equivalent to (UpdatableDoubleArray)newUnresizableArray(double.class, initialLength).
 UpdatableFloatArray newUnresizableFloatArray(long length)
          Equivalent to (UpdatableFloatArray)newUnresizableArray(float.class, initialLength).
 UpdatableIntArray newUnresizableIntArray(long length)
          Equivalent to (UpdatableIntArray)newUnresizableArray(int.class, initialLength).
 UpdatableArray newUnresizableLazyCopy(Array array)
          Equivalent to newLazyCopy(Array) method with the only difference, that the returned array is unresizable.
 UpdatableLongArray newUnresizableLongArray(long length)
          Equivalent to (UpdatableLongArray)newUnresizableArray(long.class, initialLength).
<E> UpdatableObjectArray<E>
newUnresizableObjectArray(java.lang.Class<E> elementType, long length)
          Equivalent to (UpdatableObjectArray<E>)newUnresizableArray(elementType, initialLength).
 UpdatableShortArray newUnresizableShortArray(long length)
          Equivalent to (UpdatableShortArray)newUnresizableArray(short.class, initialLength).
 UpdatableBitArray valueOf(boolean[] array)
          Equivalent to (UpdatableBitArray)valueOf((Object)array).
 UpdatableBitArray valueOf(boolean[] array, int offset, int count)
          Equivalent to (UpdatableBitArray)valueOf((Object)array, offset, count).
 UpdatableByteArray valueOf(byte[] array)
          Equivalent to (UpdatableByteArray)valueOf((Object)array).
 UpdatableByteArray valueOf(byte[] array, int offset, int count)
          Equivalent to (UpdatableByteArray)valueOf((Object)array, offset, count).
 UpdatableCharArray valueOf(char[] array)
          Equivalent to (UpdatableCharArray)valueOf((Object)array).
 UpdatableCharArray valueOf(char[] array, int offset, int count)
          Equivalent to (UpdatableCharArray)valueOf((Object)array, offset, count).
 UpdatableDoubleArray valueOf(double[] array)
          Equivalent to (UpdatableDoubleArray)valueOf((Object)array).
 UpdatableDoubleArray valueOf(double[] array, int offset, int count)
          Equivalent to (UpdatableDoubleArray)valueOf((Object)array, offset, count).
<E> UpdatableObjectArray<E>
valueOf(E[] array)
          Equivalent to (UpdatableObjectArray<E>)valueOf((Object)array).
<E> UpdatableObjectArray<E>
valueOf(E[] array, int offset, int count)
          Equivalent to (UpdatableObjectArray<E>)valueOf((Object)array, offset, count).
 UpdatableFloatArray valueOf(float[] array)
          Equivalent to (UpdatableFloatArray)valueOf((Object)array).
 UpdatableFloatArray valueOf(float[] array, int offset, int count)
          Equivalent to (UpdatableFloatArray)valueOf((Object)array, offset, count).
 UpdatableIntArray valueOf(int[] array)
          Equivalent to (UpdatableIntArray)valueOf((Object)array).
 UpdatableIntArray valueOf(int[] array, int offset, int count)
          Equivalent to (UpdatableIntArray)valueOf((Object)array, offset, count).
 UpdatableLongArray valueOf(long[] array)
          Equivalent to (UpdatableLongArray)valueOf((Object)array).
 UpdatableLongArray valueOf(long[] array, int offset, int count)
          Equivalent to (UpdatableLongArray)valueOf((Object)array, offset, count).
 UpdatableArray valueOf(java.lang.Object array)
          Constructs an unresizable AlgART array containing all elements of the specified Java array: array[0], array[1], ..., array[array.length - 1].
 UpdatableArray valueOf(java.lang.Object array, int offset, int count)
          Constructs an unresizable AlgART array containing count elements of the specified Java array: array[offset], array[offset + 1], ..., array[offset + count - 1].
 UpdatableShortArray valueOf(short[] array)
          Equivalent to (UpdatableShortArray)valueOf((Object)array).
 UpdatableShortArray valueOf(short[] array, int offset, int count)
          Equivalent to (UpdatableShortArray)valueOf((Object)array, offset, count).
 

Method Detail

newEmptyArray

MutableArray newEmptyArray(java.lang.Class<?> elementType)
Constructs an empty resizable array with the specified element type and a little initial capacity. It is equivalent to newEmptyArray(elementType, n), where n is some little value.

Example of usage:

     MutableFloatArray a = (MutableFloatArray)memoryModel.newEmptyArray(float.class);
 

Parameters:
elementType - the type of array elements.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if elementType is not supported of void.class.
UnsupportedElementTypeException - if elementType is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newArray(Class, long)

newEmptyArray

MutableArray newEmptyArray(java.lang.Class<?> elementType,
                           long initialCapacity)
Constructs 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 or CharArray. 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);
 

Parameters:
elementType - the type of array elements.
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if elementType is void.class or if the specified initial capacity is negative.
UnsupportedElementTypeException - if elementType is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newArray(Class, long)

newArray

MutableArray newArray(java.lang.Class<?> elementType,
                      long initialLength)
Constructs 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().

Parameters:
elementType - the type of array elements.
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if elementType is void.class or if the specified initial length is negative.
UnsupportedElementTypeException - if elementType is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyArray(Class, long), newUnresizableArray(Class, long)

newUnresizableArray

UpdatableArray newUnresizableArray(java.lang.Class<?> elementType,
                                   long length)
Constructs 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 (or newUnresizableBitArray, 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 the large memory model every resizable array is stored in the file consisting of integer number of blocks per DataFileModel.recommendedBankSize(true) bytes.

Parameters:
elementType - the type of array elements.
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if elementType is void.class or if the specified length is negative.
UnsupportedElementTypeException - if elementType is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newArray(Class, long)

newArray

MutableArray newArray(Array array)
Equivalent to newArray(array.elementType(), array.length()).

Parameters:
array - the pattern array.
Returns:
new AlgART array with the same length and element type.
Throws:
java.lang.NullPointerException - if array is null.
UnsupportedElementTypeException - if array.elementType() is not supported by this memory model.
TooLargeArrayException - if the length of passed array is too large for this memory model.
See Also:
isElementTypeSupported(Class)

newUnresizableArray

UpdatableArray newUnresizableArray(Array array)
Equivalent to newUnresizableArray(array.elementType(), array.length()).

Parameters:
array - the pattern array.
Returns:
new unresizable AlgART array with the same length and element type.
Throws:
java.lang.NullPointerException - if array is null.
UnsupportedElementTypeException - if array.elementType() is not supported by this memory model.
TooLargeArrayException - if the length of passed array is too large for this memory model.
See Also:
isElementTypeSupported(Class)

newEmptyBitArray

MutableBitArray newEmptyBitArray()
Equivalent to (MutableBitArray)newEmptyArray(boolean.class).

Example of usage:

     MutableBitArray a = memoryModel.newEmptyBitArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if boolean element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newBitArray(long)

newEmptyBitArray

MutableBitArray newEmptyBitArray(long initialCapacity)
Equivalent to (MutableBitArray)newEmptyArray(boolean.class, initialCapacity).

Example of usage:

     MutableBitArray a = memoryModel.newEmptyBitArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if boolean element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newBitArray(long)

newBitArray

MutableBitArray newBitArray(long initialLength)
Equivalent to (MutableBitArray)newArray(boolean.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if boolean element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyBitArray(long)

newUnresizableBitArray

UpdatableBitArray newUnresizableBitArray(long length)
Equivalent to (UpdatableBitArray)newUnresizableArray(boolean.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if boolean element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyBitArray(long)

newEmptyCharArray

MutableCharArray newEmptyCharArray()
Equivalent to (MutableCharArray)newEmptyArray(char.class).

Example of usage:

     MutableCharArray a = memoryModel.newEmptyCharArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if char element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newCharArray(long)

newEmptyCharArray

MutableCharArray newEmptyCharArray(long initialCapacity)
Equivalent to (MutableCharArray)newEmptyArray(char.class, initialCapacity).

Example of usage:

     MutableCharArray a = memoryModel.newEmptyCharArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if char element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newCharArray(long)

newCharArray

MutableCharArray newCharArray(long initialLength)
Equivalent to (MutableCharArray)newArray(char.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if char element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyCharArray(long)

newUnresizableCharArray

UpdatableCharArray newUnresizableCharArray(long length)
Equivalent to (UpdatableCharArray)newUnresizableArray(char.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if char element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyCharArray(long)

newEmptyByteArray

MutableByteArray newEmptyByteArray()
Equivalent to (MutableByteArray)newEmptyArray(byte.class).

Example of usage:

     MutableByteArray a = memoryModel.newEmptyByteArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if byte element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newByteArray(long)

newEmptyByteArray

MutableByteArray newEmptyByteArray(long initialCapacity)
Equivalent to (MutableByteArray)newEmptyArray(byte.class, initialCapacity).

Example of usage:

     MutableByteArray a = memoryModel.newEmptyByteArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if byte element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newByteArray(long)

newByteArray

MutableByteArray newByteArray(long initialLength)
Equivalent to (MutableByteArray)newArray(byte.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if byte element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyByteArray(long)

newUnresizableByteArray

UpdatableByteArray newUnresizableByteArray(long length)
Equivalent to (UpdatableByteArray)newUnresizableArray(byte.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if byte element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyByteArray(long)

newEmptyShortArray

MutableShortArray newEmptyShortArray()
Equivalent to (MutableShortArray)newEmptyArray(short.class).

Example of usage:

     MutableShortArray a = memoryModel.newEmptyShortArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if short element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newShortArray(long)

newEmptyShortArray

MutableShortArray newEmptyShortArray(long initialCapacity)
Equivalent to (MutableShortArray)newEmptyArray(short.class, initialCapacity).

Example of usage:

     MutableShortArray a = memoryModel.newEmptyShortArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if short element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newShortArray(long)

newShortArray

MutableShortArray newShortArray(long initialLength)
Equivalent to (MutableShortArray)newArray(short.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if short element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyShortArray(long)

newUnresizableShortArray

UpdatableShortArray newUnresizableShortArray(long length)
Equivalent to (UpdatableShortArray)newUnresizableArray(short.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if short element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyShortArray(long)

newEmptyIntArray

MutableIntArray newEmptyIntArray()
Equivalent to (MutableIntArray)newEmptyArray(int.class).

Example of usage:

     MutableIntArray a = memoryModel.newEmptyIntArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if int element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newIntArray(long)

newEmptyIntArray

MutableIntArray newEmptyIntArray(long initialCapacity)
Equivalent to (MutableIntArray)newEmptyArray(int.class, initialCapacity).

Example of usage:

     MutableIntArray a = memoryModel.newEmptyIntArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if int element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newIntArray(long)

newIntArray

MutableIntArray newIntArray(long initialLength)
Equivalent to (MutableIntArray)newArray(int.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if int element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyIntArray(long)

newUnresizableIntArray

UpdatableIntArray newUnresizableIntArray(long length)
Equivalent to (UpdatableIntArray)newUnresizableArray(int.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if int element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyIntArray(long)

newEmptyLongArray

MutableLongArray newEmptyLongArray()
Equivalent to (MutableLongArray)newEmptyArray(long.class).

Example of usage:

     MutableLongArray a = memoryModel.newEmptyLongArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if long element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newLongArray(long)

newEmptyLongArray

MutableLongArray newEmptyLongArray(long initialCapacity)
Equivalent to (MutableLongArray)newEmptyArray(long.class, initialCapacity).

Example of usage:

     MutableLongArray a = memoryModel.newEmptyLongArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if long element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newLongArray(long)

newLongArray

MutableLongArray newLongArray(long initialLength)
Equivalent to (MutableLongArray)newArray(long.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if long element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyLongArray(long)

newUnresizableLongArray

UpdatableLongArray newUnresizableLongArray(long length)
Equivalent to (UpdatableLongArray)newUnresizableArray(long.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if long element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyLongArray(long)

newEmptyFloatArray

MutableFloatArray newEmptyFloatArray()
Equivalent to (MutableFloatArray)newEmptyArray(float.class).

Example of usage:

     MutableFloatArray a = memoryModel.newEmptyFloatArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if float element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newFloatArray(long)

newEmptyFloatArray

MutableFloatArray newEmptyFloatArray(long initialCapacity)
Equivalent to (MutableFloatArray)newEmptyArray(float.class, initialCapacity).

Example of usage:

     MutableFloatArray a = memoryModel.newEmptyFloatArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if float element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newFloatArray(long)

newFloatArray

MutableFloatArray newFloatArray(long initialLength)
Equivalent to (MutableFloatArray)newArray(float.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if float element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyFloatArray(long)

newUnresizableFloatArray

UpdatableFloatArray newUnresizableFloatArray(long length)
Equivalent to (UpdatableFloatArray)newUnresizableArray(float.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if float element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyFloatArray(long)

newEmptyDoubleArray

MutableDoubleArray newEmptyDoubleArray()
Equivalent to (MutableDoubleArray)newEmptyArray(double.class).

Example of usage:

     MutableDoubleArray a = memoryModel.newEmptyDoubleArray();
 

Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if double element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newDoubleArray(long)

newEmptyDoubleArray

MutableDoubleArray newEmptyDoubleArray(long initialCapacity)
Equivalent to (MutableDoubleArray)newEmptyArray(double.class, initialCapacity).

Example of usage:

     MutableDoubleArray a = memoryModel.newEmptyDoubleArray(10000);
 

Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if double element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newDoubleArray(long)

newDoubleArray

MutableDoubleArray newDoubleArray(long initialLength)
Equivalent to (MutableDoubleArray)newArray(double.class, initialLength).

Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if double element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyDoubleArray(long)

newUnresizableDoubleArray

UpdatableDoubleArray newUnresizableDoubleArray(long length)
Equivalent to (UpdatableDoubleArray)newUnresizableArray(double.class, initialLength).

Parameters:
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if double element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyDoubleArray(long)

newEmptyObjectArray

<E> MutableObjectArray<E> newEmptyObjectArray(java.lang.Class<E> elementType)
Equivalent to (MutableObjectArray<E>)newEmptyArray(elementType).

Example of usage:

     MutableObjectArray<String> a =
     memoryModel.<String>newEmptyObjectArray(Class elementType);
 

Parameters:
elementType - the type of array elements.
Returns:
created AlgART array.
Throws:
UnsupportedElementTypeException - if this element type is not supported by this memory model.
See Also:
isElementTypeSupported(Class), newObjectArray(Class elementType, long)

newEmptyObjectArray

<E> MutableObjectArray<E> newEmptyObjectArray(java.lang.Class<E> elementType,
                                              long initialCapacity)
Equivalent to (MutableObjectArray<E>)newEmptyArray(elementType, initialCapacity).

Example of usage:

     MutableObjectArray<String> a =
     memoryModel.<String>newEmptyObjectArray(10000);
 

Parameters:
elementType - the type of array elements.
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative.
UnsupportedElementTypeException - if this element type is not supported by this memory model.
TooLargeArrayException - if the specified initial capacity is too large for this memory model.
See Also:
isElementTypeSupported(Class), newObjectArray(Class elementType, long)

newObjectArray

<E> MutableObjectArray<E> newObjectArray(java.lang.Class<E> elementType,
                                         long initialLength)
Equivalent to (MutableObjectArray<E>)newArray(elementType, initialLength).

Parameters:
elementType - the type of array elements.
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified initial length is negative.
UnsupportedElementTypeException - if this element type is not supported by this memory model.
TooLargeArrayException - if the specified initial length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyObjectArray(Class elementType, long)

newUnresizableObjectArray

<E> UpdatableObjectArray<E> newUnresizableObjectArray(java.lang.Class<E> elementType,
                                                      long length)
Equivalent to (UpdatableObjectArray<E>)newUnresizableArray(elementType, initialLength).

Parameters:
elementType - the type of array elements.
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if elementType is null.
java.lang.IllegalArgumentException - if the specified length is negative.
UnsupportedElementTypeException - if this element type is not supported by this memory model.
TooLargeArrayException - if the specified length is too large for this memory model.
See Also:
isElementTypeSupported(Class), newEmptyObjectArray(Class elementType, long)

newLazyCopy

MutableArray newLazyCopy(Array array)
Constructs a resizable array with the same content as the passed one, where the actual copying the elements will be deferred as long as possible, maybe, until the first access to elements. The capacity of new array will be equal to its length (i.e. array.length()).

More precisely, this method does the same things as the following operators:

 MutableArray result = thisMemoryModel.newArray(array.elementType(), array.length());
 result.copy(array); // now the result is the copy of the source array
 
with the only difference that the copying, maybe, will not be performed immediately. If you will not modify the source array, the array, returned by this method, will work absolutely identically to the result array in the example, listed above. If you will modify the source array after calling this method, the precise content of the returned array will be unspecified.

Any changes, performed in the returned array, will never be reflected in the source array. In other words, any corrections in the returned lazy copy do not affect the source array.

The Array.flushResources(ArrayContext) and Array.freeResources(ArrayContext) methods, called in the returned array, guarantee completion of all deferred copying. Since calling those methods, the returned array always becomes the actual, not lazy copy of the source one.

The described lazy copying is supported not by all memory models. In this package, only LargeMemoryModel completely supports this. Other memory models of this package inherit implementation from AbstractMemoryModel.newLazyCopy(Array), where this method, if possible (if the type of the array is suitable), returns array.asCopyOnNextWrite(), and in other cases just performs the actual copying as described in the code example above.

Parameters:
array - the source array.
Returns:
the lazy copy of the source array, if lazy copying is supported by the memory model, or the usual identical copy of the source array in other case.
Throws:
java.lang.NullPointerException - if the argument is null.
UnsupportedElementTypeException - if the element type of the passed array is not supported by this memory model.
TooLargeArrayException - if the length of the passed array is too large for this memory model.

newUnresizableLazyCopy

UpdatableArray newUnresizableLazyCopy(Array array)
Equivalent to newLazyCopy(Array) method with the only difference, that the returned array is unresizable. The capacity of new array will be equal to its length (i.e. array.length()).

As well as for newLazyCopy(Array), this method does the same things as the following operators:

 UpdatableArray result = thisMemoryModel.newUnresizableArray(array.elementType(), array.length());
 result.copy(array); // now the result is the copy of the source array
 
with the only difference that the copying, maybe, will be deferred.

The analogous result may be obtained the following call: newLazyCopy(array).asUnresizable(). However, such call may require much more resources than this method. See newUnresizableArray(Class, long) method to learn more about this difference.

The described lazy copying is supported not by all memory models. In this package, only LargeMemoryModel completely supports this. Other memory models of this package inherit implementation from AbstractMemoryModel.newUnresizableLazyCopy(Array), where this method, if possible (if the type of the array is suitable), returns array.asCopyOnNextWrite(), and in other cases just performs the actual copying as described in the code example above.

Parameters:
array - the source array.
Returns:
the lazy unresizable copy of the source array, if lazy copying is supported by the memory model, or the usual identical unresizable copy of the source array in other case.
Throws:
java.lang.NullPointerException - if the argument is null.
UnsupportedElementTypeException - if the element type of the passed array is not supported by this memory model.
TooLargeArrayException - if the length of the passed array is too large for this memory model.

newMatrix

<T extends UpdatableArray> Matrix<T> newMatrix(java.lang.Class<T> arraySupertype,
                                               java.lang.Class<?> elementType,
                                               long... dim)
Constructs a zero-filled matrix with the specified element type and dimensions.

The AlgART array, that backs the new matrix (and is will be returned by Matrix.array() method), will be unresizable. It is created by the following call: newUnresizableArray(elementType, len), where len is the product of all passed dimensions: len = dim[0] * dim[1] * .... The Matrix.dimCount() method will return dim.length, and Matrix.dim(n) method will return dim[n].

The arraySupertype argument must be equal to or supertype of the class of the underlying array, created by the call specified above. In other case, ClassCastException is thrown. (This check is performed at the very beginning, before actual calling newUnresizableArray and allocating memory.) Also arraySupertype argument must not be MutableArray or its subtype, because the underlying array of any matrix is always unresizable. This argument allows to use this method for safe creating a matrix with the required generics type parameter.

The dim argument is cloned by this method: no references to it are maintained by the created matrix.

Parameters:
arraySupertype - the desired type of the underlying array (the generic argument of the matrix type).
elementType - the type of matrix elements.
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if elementType or dim is null.
java.lang.IllegalArgumentException - if elementType is void.class, or if arraySupertype is MutableArray or its subtype, or if the specified dimensions are incorrect: dim.length == 0, dim[n] < 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
java.lang.ClassCastException - if arraySupertype and elementType do not match.
UnsupportedElementTypeException - if elementType is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
Matrix, isElementTypeSupported(Class), newArray(Class, long), newMatrix(Class, Matrix), Matrices.matrix(Array, long...), Matrices.checkNewMatrixType(Class, Class)

newMatrix

<T extends UpdatableArray> Matrix<T> newMatrix(long maxSizeAllocatedInJavaMemory,
                                               java.lang.Class<T> arraySupertype,
                                               java.lang.Class<?> elementType,
                                               long... dim)
An analog of newMatrix(Class, Class, long...), which automatically uses SignalMemoryModel instead of this memory model if the required matrix size is not greater than maxSizeAllocatedInJavaMemory bytes.

This method is equivalent to the following:

     (Arrays.sizeOf(elementType, Arrays.longMul(dim)) <= maxSizeAllocatedInJavaMemory ?
         Arrays.SMM :
         thisInstance)
     .newMatrix(arraySupertype, elementType, dim);
 

The typical value for maxSizeAllocatedInJavaMemory argument is the result of Arrays.SystemSettings.maxTempJavaMemory() method.

Parameters:
maxSizeAllocatedInJavaMemory - the maximal amount of required memory, for which this method just redirects to the same method of SimpleMemoryModel.getInstance()
arraySupertype - the desired type of the underlying array (the generic argument of the matrix type).
elementType - the type of matrix elements.
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if elementType or dim is null.
java.lang.IllegalArgumentException - if elementType is void.class, or if arraySupertype is MutableArray or its subtype, or if the specified dimensions are incorrect: dim.length == 0, dim[n] < 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
java.lang.ClassCastException - if arraySupertype and elementType do not match.
UnsupportedElementTypeException - if elementType is not supported by this memory model or, for a matrix smaller than maxSizeAllocatedInJavaMemory, by SimpleMemoryModel.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model or, for a matrix smaller than maxSizeAllocatedInJavaMemory, by SimpleMemoryModel.

newMatrix

<T extends UpdatableArray> Matrix<T> newMatrix(java.lang.Class<T> arraySupertype,
                                               Matrix<?> matrix)
Equivalent to newMatrix(arraySupertype, matrix.elementType(), matrix.dimensions()).

Parameters:
arraySupertype - the desired type of the underlying array of the new matrix (usually an updatable version of the built-in array of the source matrix).
matrix - the pattern matrix.
Returns:
new matrix with the same dimensions and element type.
Throws:
java.lang.NullPointerException - if matrix is null.
java.lang.ClassCastException - if arraySupertype and matrix.elementType() do not match.
UnsupportedElementTypeException - if matrix.elementType() is not supported by this memory model.
TooLargeArrayException - if the size of passed matrix is too large for this memory model.
See Also:
isElementTypeSupported(Class), newStructuredMatrix(Class, Matrix), Matrix

newStructuredMatrix

<T extends UpdatableArray> Matrix<T> newStructuredMatrix(java.lang.Class<T> arraySupertype,
                                                         Matrix<?> matrix)
Equivalent to newMatrix(arraySupertype, matrix).structureLike(matrix).

Parameters:
arraySupertype - the desired type of the underlying array of the new matrix (usually an updatable version of the built-in array of the source matrix).
matrix - the pattern matrix.
Returns:
new matrix with the same dimensions, element type and similar ordering elements.
Throws:
java.lang.NullPointerException - if matrix is null.
java.lang.ClassCastException - if arraySupertype and matrix.elementType() do not match.
UnsupportedElementTypeException - if matrix.elementType() is not supported by this memory model.
TooLargeArrayException - if the size of passed matrix is too large for this memory model.
See Also:
isElementTypeSupported(Class), Matrix

newBitMatrix

Matrix<UpdatableBitArray> newBitMatrix(long... dim)
Equivalent to newMatrix(UpdatableBitArray.class, boolean.class, dim).

Example of usage:

     Matrix<UpdatableBitArray> m = memoryModel.newBitMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if boolean element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newBitArray(long), Matrices.matrix(Array, long...), Matrix

newCharMatrix

Matrix<UpdatableCharArray> newCharMatrix(long... dim)
Equivalent to newMatrix(UpdatableCharArray.class, char.class, dim).

Example of usage:

     Matrix<UpdatableCharArray> m = memoryModel.newCharMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if char element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newCharArray(long), Matrices.matrix(Array, long...), Matrix

newByteMatrix

Matrix<UpdatableByteArray> newByteMatrix(long... dim)
Equivalent to newMatrix(UpdatableByteArray.class, byte.class, dim).

Example of usage:

     Matrix<UpdatableByteArray> m = memoryModel.newByteMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if byte element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newByteArray(long), Matrices.matrix(Array, long...), Matrix

newShortMatrix

Matrix<UpdatableShortArray> newShortMatrix(long... dim)
Equivalent to newMatrix(UpdatableShortArray.class, short.class, dim).

Example of usage:

     Matrix<UpdatableShortArray> m = memoryModel.newShortMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if short element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newShortArray(long), Matrices.matrix(Array, long...), Matrix

newIntMatrix

Matrix<UpdatableIntArray> newIntMatrix(long... dim)
Equivalent to newMatrix(UpdatableIntArray.class, int.class, dim).

Example of usage:

     Matrix<UpdatableIntArray> m = memoryModel.newIntMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if int element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newIntArray(long), Matrices.matrix(Array, long...), Matrix

newLongMatrix

Matrix<UpdatableLongArray> newLongMatrix(long... dim)
Equivalent to newMatrix(UpdatableLongArray.class, long.class, dim).

Example of usage:

     Matrix<UpdatableLongArray> m = memoryModel.newLongMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if long element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newLongArray(long), Matrices.matrix(Array, long...), Matrix

newFloatMatrix

Matrix<UpdatableFloatArray> newFloatMatrix(long... dim)
Equivalent to newMatrix(UpdatableFloatArray.class, float.class, dim).

Example of usage:

     Matrix<UpdatableFloatArray> m = memoryModel.newFloatMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if float element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newFloatArray(long), Matrices.matrix(Array, long...), Matrix

newDoubleMatrix

Matrix<UpdatableDoubleArray> newDoubleMatrix(long... dim)
Equivalent to newMatrix(UpdatableDoubleArray.class, double.class, dim).

Example of usage:

     Matrix<UpdatableDoubleArray> m = memoryModel.newDoubleMatrix(100, 100);
 

Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if double element type is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newDoubleArray(long), Matrices.matrix(Array, long...), Matrix

newObjectMatrix

<E> Matrix<UpdatableObjectArray<E>> newObjectMatrix(java.lang.Class<E> elementType,
                                                    long... dim)
Equivalent to newMatrix(UpdatableObjectArray.class, elementType, dim).

Example of usage:

     Matrix<UpdatableObjectArray<String>> m =
         memoryModel.newObjectMatrix(String.class, 100, 100);
 

Parameters:
elementType - the type of matrix elements.
dim - the dimensions of the matrix.
Returns:
created matrix.
Throws:
java.lang.NullPointerException - if dim is null.
java.lang.IllegalArgumentException - if the specified dimensions are incorrect: dim.length == 0, dim[n] <= 0 for some n, or the product of all specified dimensions is greater than Long.MAX_VALUE.
UnsupportedElementTypeException - if elementType is not supported by this memory model.
TooLargeArrayException - if the product of all specified dimensions is too large for this memory model.
See Also:
isElementTypeSupported(Class), newObjectArray(Class, long), Matrices.matrix(Array, long...), Matrix

newLazyCopy

<T extends UpdatableArray> Matrix<T> newLazyCopy(java.lang.Class<T> arraySupertype,
                                                 Matrix<?> matrix)
Equivalent to matrix.matrix(newUnresizableLazyCopy(matrix.array())).cast(arraySupertype).

Parameters:
arraySupertype - the desired type of the underlying array of the new lazy copy (usually an updatable version of the built-in array of the source matrix).
matrix - the source matrix.
Returns:
the lazy copy of the source matrix, if lazy copying is supported by the memory model, or the usual identical copy of the source matrix in other case.
Throws:
java.lang.NullPointerException - if onn of the arguments is null.
java.lang.ClassCastException - if arraySupertype does not match to the element type of the passed matrix.
UnsupportedElementTypeException - if the element type of the passed matrix is not supported by this memory model.
TooLargeArrayException - if the total size of the passed matrix is too large for this memory model.

valueOf

UpdatableArray valueOf(java.lang.Object array,
                       int offset,
                       int count)
Constructs 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 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()).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableArray valueOf(java.lang.Object array)
Constructs 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 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.

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.

valueOf

UpdatableBitArray valueOf(boolean[] array,
                          int offset,
                          int count)
Equivalent to (UpdatableBitArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableBitArray valueOf(boolean[] array)
Equivalent to (UpdatableBitArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

UpdatableCharArray valueOf(char[] array,
                           int offset,
                           int count)
Equivalent to (UpdatableCharArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableCharArray valueOf(char[] array)
Equivalent to (UpdatableCharArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

UpdatableByteArray valueOf(byte[] array,
                           int offset,
                           int count)
Equivalent to (UpdatableByteArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableByteArray valueOf(byte[] array)
Equivalent to (UpdatableByteArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

UpdatableShortArray valueOf(short[] array,
                            int offset,
                            int count)
Equivalent to (UpdatableShortArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableShortArray valueOf(short[] array)
Equivalent to (UpdatableShortArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

UpdatableIntArray valueOf(int[] array,
                          int offset,
                          int count)
Equivalent to (UpdatableIntArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableIntArray valueOf(int[] array)
Equivalent to (UpdatableIntArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

UpdatableLongArray valueOf(long[] array,
                           int offset,
                           int count)
Equivalent to (UpdatableLongArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableLongArray valueOf(long[] array)
Equivalent to (UpdatableLongArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

UpdatableFloatArray valueOf(float[] array,
                            int offset,
                            int count)
Equivalent to (UpdatableFloatArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableFloatArray valueOf(float[] array)
Equivalent to (UpdatableFloatArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

UpdatableDoubleArray valueOf(double[] array,
                             int offset,
                             int count)
Equivalent to (UpdatableDoubleArray)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

UpdatableDoubleArray valueOf(double[] array)
Equivalent to (UpdatableDoubleArray)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

valueOf

<E> UpdatableObjectArray<E> valueOf(E[] array,
                                    int offset,
                                    int count)
Equivalent to (UpdatableObjectArray<E>)valueOf((Object)array, offset, count).

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.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IndexOutOfBoundsException - if copying would cause access of data outside the passed Java array.

valueOf

<E> UpdatableObjectArray<E> valueOf(E[] array)
Equivalent to (UpdatableObjectArray<E>)valueOf((Object)array).

Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.
Throws:
java.lang.NullPointerException - if array argument is null.
java.lang.IllegalArgumentException - if array argument is not a Java array.

isElementTypeSupported

boolean isElementTypeSupported(java.lang.Class<?> elementType)
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 throw UnsupportedElementTypeException. The result is not defined for void.class.

Parameters:
elementType - the type of array elements.
Returns:
true if this memory model supports this element type.
Throws:
java.lang.NullPointerException - if elementType is null.

areAllPrimitiveElementTypesSupported

boolean areAllPrimitiveElementTypesSupported()
Returns true if this memory model can create arrays with all primitive element types: boolean, char, byte, short, int, long, float, double.

Returns:
true if this memory model supports all primitive element types.
See Also:
isElementTypeSupported(Class)

areAllElementTypesSupported

boolean areAllElementTypesSupported()
Returns true if this memory model can create arrays with all element types. This package offers only one such memory model: SimpleMemoryModel.

Returns:
true if this memory model supports element types.
See Also:
isElementTypeSupported(Class)

maxSupportedLength

long maxSupportedLength(java.lang.Class<?> elementType)
Returnes maximal possible length of arrays with the specified element type supported by this memory model. If the capacity / length passed to newEmptyArray(Class, long) / newArray(Class, long) methods is greater than the result of this method, they will throw TooLargeArrayException. The result is not defined it the passed element type is not supported by this memory model (for example, it may be -1).

For some memory model, the method may be not enough informative: creation methods may throw TooLargeArrayException even if the passed capacity / length is less than the result of this method. Please refer to the documentation of the corresponding memory model to know the precise behavior of this method. In any case, maximal possible array length is restricted by the amount of Java memory.

Parameters:
elementType - the type of array elements.
Returns:
maximal possible length of arrays supported by this memory model.
Throws:
java.lang.NullPointerException - if elementType is null.

isCreatedBy

boolean isCreatedBy(Array array)
Returns true if the passed array was created by this (or identical) memory model.

For SimpleMemoryModel and BufferMemoryModel, "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 the data file factory.

For CombinedMemoryModel, "identical" means that the memory model is also combined and was created with the same instance of the combiner.

Returns false if the passed argument is null.

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.