AlgART Home

net.algart.arrays
Class AbstractMemoryModel

java.lang.Object
  extended by net.algart.arrays.AbstractMemoryModel
All Implemented Interfaces:
MemoryModel
Direct Known Subclasses:
BufferMemoryModel, CombinedMemoryModel, LargeMemoryModel, SignalMemoryModel, SimpleMemoryModel

public abstract class AbstractMemoryModel
extends java.lang.Object
implements MemoryModel

A skeletal implementation of the MemoryModel interface to minimize the effort required to implement this interface.

This class implements all concrete newEmptyXxxArray, newXxxArray and newUnresizableXxxArray methods, and also all valueOf methods via trivial calls of corresponding newEmptyArray and newArray methods. This class implements all concrete newXxxMatrix via trivial calls of newMatrix method. It also offers a simple implementation of some other methods: see comments to them.

AlgART Laboratory 2007-2013

Since:
JDK 1.5
Version:
1.2
Author:
Daniel Alievsky

Constructor Summary
Constructor and Description
AbstractMemoryModel()
           
 
Method Summary
Modifier and Type Method and Description
abstract  boolean areAllElementTypesSupported()
          Returns true if this memory model can create arrays with all element types.
abstract  boolean areAllPrimitiveElementTypesSupported()
          Returns true if this memory model can create arrays with all primitive element types: boolean, char, byte, short, int, long, float, double.
abstract  boolean isCreatedBy(Array array)
          Returns true if the passed array was created by this (or identical) memory model.
abstract  boolean isElementTypeSupported(java.lang.Class<?> elementType)
          Returns true if this memory model can create arrays with this element type.
abstract  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()).
abstract  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).
abstract  MutableArray newEmptyArray(java.lang.Class<?> elementType)
          Constructs an empty resizable array with the specified element type and a little initial capacity.
abstract  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)
          This implementation returns array.asCopyOnNextWrite(), if the array is resizable and created by this memory model, or usual actual copy of the array in other case.
<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)
          This method is fully implemented in this class.
<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)
          This method is fully implemented in this class.
<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()).
abstract  UpdatableArray newUnresizableArray(java.lang.Class<?> elementType, long length)
          Constructs a zero-filled unresizable array with the specified element type and length.
 UpdatableBitArray newUnresizableBitArray(long initialLength)
          Equivalent to (UpdatableBitArray)newUnresizableArray(boolean.class, initialLength).
 UpdatableByteArray newUnresizableByteArray(long initialLength)
          Equivalent to (UpdatableByteArray)newUnresizableArray(byte.class, initialLength).
 UpdatableCharArray newUnresizableCharArray(long initialLength)
          Equivalent to (UpdatableCharArray)newUnresizableArray(char.class, initialLength).
 UpdatableDoubleArray newUnresizableDoubleArray(long initialLength)
          Equivalent to (UpdatableDoubleArray)newUnresizableArray(double.class, initialLength).
 UpdatableFloatArray newUnresizableFloatArray(long initialLength)
          Equivalent to (UpdatableFloatArray)newUnresizableArray(float.class, initialLength).
 UpdatableIntArray newUnresizableIntArray(long initialLength)
          Equivalent to (UpdatableIntArray)newUnresizableArray(int.class, initialLength).
 UpdatableArray newUnresizableLazyCopy(Array array)
          This implementation returns array.asCopyOnNextWrite(), if the array is updatable and created by this memory model, or usual actual copy of the array in other case.
 UpdatableLongArray newUnresizableLongArray(long initialLength)
          Equivalent to (UpdatableLongArray)newUnresizableArray(long.class, initialLength).
<E> UpdatableObjectArray<E>
newUnresizableObjectArray(java.lang.Class<E> elementType, long initialLength)
          Equivalent to (UpdatableObjectArray<E>)newUnresizableArray(elementType, initialLength).
 UpdatableShortArray newUnresizableShortArray(long initialLength)
          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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMemoryModel

public AbstractMemoryModel()
Method Detail

newEmptyArray

public abstract MutableArray newEmptyArray(java.lang.Class<?> elementType)
Description copied from interface: MemoryModel
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);
 

Specified by:
newEmptyArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newArray(Class, long)

newEmptyArray

public abstract MutableArray newEmptyArray(java.lang.Class<?> elementType,
                                           long initialCapacity)
Description copied from interface: MemoryModel
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);
 

Specified by:
newEmptyArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newArray(Class, long)

newArray

public abstract MutableArray newArray(java.lang.Class<?> elementType,
                                      long initialLength)
Description copied from interface: MemoryModel
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().

Specified by:
newArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyArray(Class, long), MemoryModel.newUnresizableArray(Class, long)

newUnresizableArray

public abstract UpdatableArray newUnresizableArray(java.lang.Class<?> elementType,
                                                   long length)
Description copied from interface: MemoryModel
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.

Specified by:
newUnresizableArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
length - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newArray(Class, long)

newArray

public MutableArray newArray(Array array)
Description copied from interface: MemoryModel
Equivalent to newArray(array.elementType(), array.length()).

Specified by:
newArray in interface MemoryModel
Parameters:
array - the pattern array.
Returns:
new AlgART array with the same length and element type.
See Also:
MemoryModel.isElementTypeSupported(Class)

newUnresizableArray

public UpdatableArray newUnresizableArray(Array array)
Description copied from interface: MemoryModel
Equivalent to newUnresizableArray(array.elementType(), array.length()).

Specified by:
newUnresizableArray in interface MemoryModel
Parameters:
array - the pattern array.
Returns:
new unresizable AlgART array with the same length and element type.
See Also:
MemoryModel.isElementTypeSupported(Class)

newEmptyBitArray

public MutableBitArray newEmptyBitArray()
Description copied from interface: MemoryModel
Equivalent to (MutableBitArray)newEmptyArray(boolean.class).

Example of usage:

     MutableBitArray a = memoryModel.newEmptyBitArray();
 

Specified by:
newEmptyBitArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newBitArray(long)

newEmptyBitArray

public MutableBitArray newEmptyBitArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableBitArray)newEmptyArray(boolean.class, initialCapacity).

Example of usage:

     MutableBitArray a = memoryModel.newEmptyBitArray(10000);
 

Specified by:
newEmptyBitArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newBitArray(long)

newBitArray

public MutableBitArray newBitArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableBitArray)newArray(boolean.class, initialLength).

Specified by:
newBitArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyBitArray(long)

newUnresizableBitArray

public UpdatableBitArray newUnresizableBitArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableBitArray)newUnresizableArray(boolean.class, initialLength).

Specified by:
newUnresizableBitArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyBitArray(long)

newEmptyCharArray

public MutableCharArray newEmptyCharArray()
Description copied from interface: MemoryModel
Equivalent to (MutableCharArray)newEmptyArray(char.class).

Example of usage:

     MutableCharArray a = memoryModel.newEmptyCharArray();
 

Specified by:
newEmptyCharArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newCharArray(long)

newEmptyCharArray

public MutableCharArray newEmptyCharArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableCharArray)newEmptyArray(char.class, initialCapacity).

Example of usage:

     MutableCharArray a = memoryModel.newEmptyCharArray(10000);
 

Specified by:
newEmptyCharArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newCharArray(long)

newCharArray

public MutableCharArray newCharArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableCharArray)newArray(char.class, initialLength).

Specified by:
newCharArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyCharArray(long)

newUnresizableCharArray

public UpdatableCharArray newUnresizableCharArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableCharArray)newUnresizableArray(char.class, initialLength).

Specified by:
newUnresizableCharArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyCharArray(long)

newEmptyByteArray

public MutableByteArray newEmptyByteArray()
Description copied from interface: MemoryModel
Equivalent to (MutableByteArray)newEmptyArray(byte.class).

Example of usage:

     MutableByteArray a = memoryModel.newEmptyByteArray();
 

Specified by:
newEmptyByteArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newByteArray(long)

newEmptyByteArray

public MutableByteArray newEmptyByteArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableByteArray)newEmptyArray(byte.class, initialCapacity).

Example of usage:

     MutableByteArray a = memoryModel.newEmptyByteArray(10000);
 

Specified by:
newEmptyByteArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newByteArray(long)

newByteArray

public MutableByteArray newByteArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableByteArray)newArray(byte.class, initialLength).

Specified by:
newByteArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyByteArray(long)

newUnresizableByteArray

public UpdatableByteArray newUnresizableByteArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableByteArray)newUnresizableArray(byte.class, initialLength).

Specified by:
newUnresizableByteArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyByteArray(long)

newEmptyShortArray

public MutableShortArray newEmptyShortArray()
Description copied from interface: MemoryModel
Equivalent to (MutableShortArray)newEmptyArray(short.class).

Example of usage:

     MutableShortArray a = memoryModel.newEmptyShortArray();
 

Specified by:
newEmptyShortArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newShortArray(long)

newEmptyShortArray

public MutableShortArray newEmptyShortArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableShortArray)newEmptyArray(short.class, initialCapacity).

Example of usage:

     MutableShortArray a = memoryModel.newEmptyShortArray(10000);
 

Specified by:
newEmptyShortArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newShortArray(long)

newShortArray

public MutableShortArray newShortArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableShortArray)newArray(short.class, initialLength).

Specified by:
newShortArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyShortArray(long)

newUnresizableShortArray

public UpdatableShortArray newUnresizableShortArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableShortArray)newUnresizableArray(short.class, initialLength).

Specified by:
newUnresizableShortArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyShortArray(long)

newEmptyIntArray

public MutableIntArray newEmptyIntArray()
Description copied from interface: MemoryModel
Equivalent to (MutableIntArray)newEmptyArray(int.class).

Example of usage:

     MutableIntArray a = memoryModel.newEmptyIntArray();
 

Specified by:
newEmptyIntArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newIntArray(long)

newEmptyIntArray

public MutableIntArray newEmptyIntArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableIntArray)newEmptyArray(int.class, initialCapacity).

Example of usage:

     MutableIntArray a = memoryModel.newEmptyIntArray(10000);
 

Specified by:
newEmptyIntArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newIntArray(long)

newIntArray

public MutableIntArray newIntArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableIntArray)newArray(int.class, initialLength).

Specified by:
newIntArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyIntArray(long)

newUnresizableIntArray

public UpdatableIntArray newUnresizableIntArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableIntArray)newUnresizableArray(int.class, initialLength).

Specified by:
newUnresizableIntArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyIntArray(long)

newEmptyLongArray

public MutableLongArray newEmptyLongArray()
Description copied from interface: MemoryModel
Equivalent to (MutableLongArray)newEmptyArray(long.class).

Example of usage:

     MutableLongArray a = memoryModel.newEmptyLongArray();
 

Specified by:
newEmptyLongArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newLongArray(long)

newEmptyLongArray

public MutableLongArray newEmptyLongArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableLongArray)newEmptyArray(long.class, initialCapacity).

Example of usage:

     MutableLongArray a = memoryModel.newEmptyLongArray(10000);
 

Specified by:
newEmptyLongArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newLongArray(long)

newLongArray

public MutableLongArray newLongArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableLongArray)newArray(long.class, initialLength).

Specified by:
newLongArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyLongArray(long)

newUnresizableLongArray

public UpdatableLongArray newUnresizableLongArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableLongArray)newUnresizableArray(long.class, initialLength).

Specified by:
newUnresizableLongArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyLongArray(long)

newEmptyFloatArray

public MutableFloatArray newEmptyFloatArray()
Description copied from interface: MemoryModel
Equivalent to (MutableFloatArray)newEmptyArray(float.class).

Example of usage:

     MutableFloatArray a = memoryModel.newEmptyFloatArray();
 

Specified by:
newEmptyFloatArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newFloatArray(long)

newEmptyFloatArray

public MutableFloatArray newEmptyFloatArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableFloatArray)newEmptyArray(float.class, initialCapacity).

Example of usage:

     MutableFloatArray a = memoryModel.newEmptyFloatArray(10000);
 

Specified by:
newEmptyFloatArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newFloatArray(long)

newFloatArray

public MutableFloatArray newFloatArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableFloatArray)newArray(float.class, initialLength).

Specified by:
newFloatArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyFloatArray(long)

newUnresizableFloatArray

public UpdatableFloatArray newUnresizableFloatArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableFloatArray)newUnresizableArray(float.class, initialLength).

Specified by:
newUnresizableFloatArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyFloatArray(long)

newEmptyDoubleArray

public MutableDoubleArray newEmptyDoubleArray()
Description copied from interface: MemoryModel
Equivalent to (MutableDoubleArray)newEmptyArray(double.class).

Example of usage:

     MutableDoubleArray a = memoryModel.newEmptyDoubleArray();
 

Specified by:
newEmptyDoubleArray in interface MemoryModel
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newDoubleArray(long)

newEmptyDoubleArray

public MutableDoubleArray newEmptyDoubleArray(long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableDoubleArray)newEmptyArray(double.class, initialCapacity).

Example of usage:

     MutableDoubleArray a = memoryModel.newEmptyDoubleArray(10000);
 

Specified by:
newEmptyDoubleArray in interface MemoryModel
Parameters:
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newDoubleArray(long)

newDoubleArray

public MutableDoubleArray newDoubleArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableDoubleArray)newArray(double.class, initialLength).

Specified by:
newDoubleArray in interface MemoryModel
Parameters:
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyDoubleArray(long)

newUnresizableDoubleArray

public UpdatableDoubleArray newUnresizableDoubleArray(long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableDoubleArray)newUnresizableArray(double.class, initialLength).

Specified by:
newUnresizableDoubleArray in interface MemoryModel
Parameters:
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyDoubleArray(long)

newEmptyObjectArray

public <E> MutableObjectArray<E> newEmptyObjectArray(java.lang.Class<E> elementType)
Description copied from interface: MemoryModel
Equivalent to (MutableObjectArray<E>)newEmptyArray(elementType).

Example of usage:

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

Specified by:
newEmptyObjectArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newObjectArray(Class elementType, long)

newEmptyObjectArray

public <E> MutableObjectArray<E> newEmptyObjectArray(java.lang.Class<E> elementType,
                                                     long initialCapacity)
Description copied from interface: MemoryModel
Equivalent to (MutableObjectArray<E>)newEmptyArray(elementType, initialCapacity).

Example of usage:

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

Specified by:
newEmptyObjectArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
initialCapacity - the initial capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newObjectArray(Class elementType, long)

newObjectArray

public <E> MutableObjectArray<E> newObjectArray(java.lang.Class<E> elementType,
                                                long initialLength)
Description copied from interface: MemoryModel
Equivalent to (MutableObjectArray<E>)newArray(elementType, initialLength).

Specified by:
newObjectArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
initialLength - the initial length and capacity of the array.
Returns:
created AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyObjectArray(Class elementType, long)

newUnresizableObjectArray

public <E> UpdatableObjectArray<E> newUnresizableObjectArray(java.lang.Class<E> elementType,
                                                             long initialLength)
Description copied from interface: MemoryModel
Equivalent to (UpdatableObjectArray<E>)newUnresizableArray(elementType, initialLength).

Specified by:
newUnresizableObjectArray in interface MemoryModel
Parameters:
elementType - the type of array elements.
initialLength - the length and capacity of the array.
Returns:
created unresizable AlgART array.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newEmptyObjectArray(Class elementType, long)

newLazyCopy

public MutableArray newLazyCopy(Array array)
This implementation returns array.asCopyOnNextWrite(), if the array is resizable and created by this memory model, or usual actual copy of the array in other case. More precisely, it is equivalent to the following operators:
 MutableArray result = (thisMemoryModel.isCreatedBy(array) && array instanceof MutableArray) ?
 ((MutableArray)array).asCopyOnNextWrite() :
 thisMemoryModel.newArray(array.elementType(), array.length()).copy(array);
 

Specified by:
newLazyCopy in interface MemoryModel
Parameters:
array - the source array.
Returns:
the usual identical copy of the source array.
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

public UpdatableArray newUnresizableLazyCopy(Array array)
This implementation returns array.asCopyOnNextWrite(), if the array is updatable and created by this memory model, or usual actual copy of the array in other case. More precisely, it is equivalent to the following operators:
 UpdatableArray result = (thisMemoryModel.isCreatedBy(array) && array instanceof UpdatableArray) ?
 ((UpdatableArray)array).asCopyOnNextWrite() :
 thisMemoryModel.newUnresizableArray(array.elementType(), array.length()).copy(array);
 

Specified by:
newUnresizableLazyCopy in interface MemoryModel
Parameters:
array - the source array.
Returns:
the usual identical unresizable copy of the source array.
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

public <T extends UpdatableArray> Matrix<T> newMatrix(java.lang.Class<T> arraySupertype,
                                                      java.lang.Class<?> elementType,
                                                      long... dim)
This method is fully implemented in this class.

Specified by:
newMatrix in interface MemoryModel
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, MemoryModel.isElementTypeSupported(Class), MemoryModel.newArray(Class, long), MemoryModel.newMatrix(Class, Matrix), Matrices.matrix(Array, long...), Matrices.checkNewMatrixType(Class, Class)

newMatrix

public <T extends UpdatableArray> Matrix<T> newMatrix(long maxSizeAllocatedInJavaMemory,
                                                      java.lang.Class<T> arraySupertype,
                                                      java.lang.Class<?> elementType,
                                                      long... dim)
This method is fully implemented in this class.

Specified by:
newMatrix in interface MemoryModel
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

public <T extends UpdatableArray> Matrix<T> newMatrix(java.lang.Class<T> arraySupertype,
                                                      Matrix<?> matrix)
Description copied from interface: MemoryModel
Equivalent to newMatrix(arraySupertype, matrix.elementType(), matrix.dimensions()).

Specified by:
newMatrix in interface MemoryModel
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.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newStructuredMatrix(Class, Matrix), Matrix

newStructuredMatrix

public <T extends UpdatableArray> Matrix<T> newStructuredMatrix(java.lang.Class<T> arraySupertype,
                                                                Matrix<?> matrix)
Description copied from interface: MemoryModel
Equivalent to newMatrix(arraySupertype, matrix).structureLike(matrix).

Specified by:
newStructuredMatrix in interface MemoryModel
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.
See Also:
MemoryModel.isElementTypeSupported(Class), Matrix

newBitMatrix

public Matrix<UpdatableBitArray> newBitMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableBitArray.class, boolean.class, dim).

Example of usage:

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

Specified by:
newBitMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newBitArray(long), Matrices.matrix(Array, long...), Matrix

newCharMatrix

public Matrix<UpdatableCharArray> newCharMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableCharArray.class, char.class, dim).

Example of usage:

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

Specified by:
newCharMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newCharArray(long), Matrices.matrix(Array, long...), Matrix

newByteMatrix

public Matrix<UpdatableByteArray> newByteMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableByteArray.class, byte.class, dim).

Example of usage:

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

Specified by:
newByteMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newByteArray(long), Matrices.matrix(Array, long...), Matrix

newShortMatrix

public Matrix<UpdatableShortArray> newShortMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableShortArray.class, short.class, dim).

Example of usage:

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

Specified by:
newShortMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newShortArray(long), Matrices.matrix(Array, long...), Matrix

newIntMatrix

public Matrix<UpdatableIntArray> newIntMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableIntArray.class, int.class, dim).

Example of usage:

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

Specified by:
newIntMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newIntArray(long), Matrices.matrix(Array, long...), Matrix

newLongMatrix

public Matrix<UpdatableLongArray> newLongMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableLongArray.class, long.class, dim).

Example of usage:

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

Specified by:
newLongMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newLongArray(long), Matrices.matrix(Array, long...), Matrix

newFloatMatrix

public Matrix<UpdatableFloatArray> newFloatMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableFloatArray.class, float.class, dim).

Example of usage:

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

Specified by:
newFloatMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newFloatArray(long), Matrices.matrix(Array, long...), Matrix

newDoubleMatrix

public Matrix<UpdatableDoubleArray> newDoubleMatrix(long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableDoubleArray.class, double.class, dim).

Example of usage:

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

Specified by:
newDoubleMatrix in interface MemoryModel
Parameters:
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newDoubleArray(long), Matrices.matrix(Array, long...), Matrix

newObjectMatrix

public <E> Matrix<UpdatableObjectArray<E>> newObjectMatrix(java.lang.Class<E> elementType,
                                                           long... dim)
Description copied from interface: MemoryModel
Equivalent to newMatrix(UpdatableObjectArray.class, elementType, dim).

Example of usage:

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

Specified by:
newObjectMatrix in interface MemoryModel
Parameters:
elementType - the type of matrix elements.
dim - the dimensions of the matrix.
Returns:
created matrix.
See Also:
MemoryModel.isElementTypeSupported(Class), MemoryModel.newObjectArray(Class, long), Matrices.matrix(Array, long...), Matrix

newLazyCopy

public <T extends UpdatableArray> Matrix<T> newLazyCopy(java.lang.Class<T> arraySupertype,
                                                        Matrix<?> matrix)
Description copied from interface: MemoryModel
Equivalent to matrix.matrix(newUnresizableLazyCopy(matrix.array())).cast(arraySupertype).

Specified by:
newLazyCopy in interface MemoryModel
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.

valueOf

public UpdatableArray valueOf(java.lang.Object array,
                              int offset,
                              int count)
Description copied from interface: MemoryModel
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()).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableArray valueOf(java.lang.Object array)
Description copied from interface: MemoryModel
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.

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableBitArray valueOf(boolean[] array,
                                 int offset,
                                 int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableBitArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableBitArray valueOf(boolean[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableBitArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableCharArray valueOf(char[] array,
                                  int offset,
                                  int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableCharArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableCharArray valueOf(char[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableCharArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableByteArray valueOf(byte[] array,
                                  int offset,
                                  int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableByteArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableByteArray valueOf(byte[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableByteArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableShortArray valueOf(short[] array,
                                   int offset,
                                   int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableShortArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableShortArray valueOf(short[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableShortArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableIntArray valueOf(int[] array,
                                 int offset,
                                 int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableIntArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableIntArray valueOf(int[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableIntArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableLongArray valueOf(long[] array,
                                  int offset,
                                  int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableLongArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableLongArray valueOf(long[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableLongArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableFloatArray valueOf(float[] array,
                                   int offset,
                                   int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableFloatArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableFloatArray valueOf(float[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableFloatArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public UpdatableDoubleArray valueOf(double[] array,
                                    int offset,
                                    int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableDoubleArray)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public UpdatableDoubleArray valueOf(double[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableDoubleArray)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

valueOf

public <E> UpdatableObjectArray<E> valueOf(E[] array,
                                           int offset,
                                           int count)
Description copied from interface: MemoryModel
Equivalent to (UpdatableObjectArray<E>)valueOf((Object)array, offset, count).

Specified by:
valueOf in interface MemoryModel
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

public <E> UpdatableObjectArray<E> valueOf(E[] array)
Description copied from interface: MemoryModel
Equivalent to (UpdatableObjectArray<E>)valueOf((Object)array).

Specified by:
valueOf in interface MemoryModel
Parameters:
array - the source Java array with elements of constructed AlgART array.
Returns:
created unresizable AlgART array.

isElementTypeSupported

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

Specified by:
isElementTypeSupported in interface MemoryModel
Parameters:
elementType - the type of array elements.
Returns:
true if this memory model supports this element type.

areAllPrimitiveElementTypesSupported

public abstract 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 interface MemoryModel
Returns:
true if this memory model supports all primitive element types.
See Also:
MemoryModel.isElementTypeSupported(Class)

areAllElementTypesSupported

public abstract 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 interface MemoryModel
Returns:
true if this memory model supports element types.
See Also:
MemoryModel.isElementTypeSupported(Class)

maxSupportedLength

public abstract long maxSupportedLength(java.lang.Class<?> elementType)
Description copied from interface: MemoryModel
Returnes maximal possible length of arrays with the specified element type supported by this memory model. If the capacity / length passed to MemoryModel.newEmptyArray(Class, long) / MemoryModel.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.

Specified by:
maxSupportedLength in interface MemoryModel
Parameters:
elementType - the type of array elements.
Returns:
maximal possible length of arrays supported by this memory model.

isCreatedBy

public abstract boolean isCreatedBy(Array array)
Description copied from interface: MemoryModel
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.

Specified by:
isCreatedBy in interface MemoryModel
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.