|
AlgART Home | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.algart.arrays.AbstractMemoryModel
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
| Constructor and Description |
|---|
AbstractMemoryModel()
|
| 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). |
|
|
newEmptyObjectArray(java.lang.Class<E> elementType)
Equivalent to (MutableObjectArray<E>) newEmptyArray(elementType). |
|
|
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. |
|
|
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). |
|
|
newMatrix(java.lang.Class<T> arraySupertype,
java.lang.Class<?> elementType,
long... dim)
This method is fully implemented in this class. |
|
|
newMatrix(java.lang.Class<T> arraySupertype,
Matrix<?> matrix)
Equivalent to newMatrix(arraySupertype, matrix.elementType(), matrix.dimensions()). |
|
|
newMatrix(long maxSizeAllocatedInJavaMemory,
java.lang.Class<T> arraySupertype,
java.lang.Class<?> elementType,
long... dim)
This method is fully implemented in this class. |
|
|
newObjectArray(java.lang.Class<E> elementType,
long initialLength)
Equivalent to (MutableObjectArray<E>) newArray(elementType, initialLength). |
|
|
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). |
|
|
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). |
|
|
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). |
|
|
valueOf(E[] array)
Equivalent to (UpdatableObjectArray<E>) valueOf((Object)array). |
|
|
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 |
|---|
public AbstractMemoryModel()
| Method Detail |
|---|
public abstract MutableArray newEmptyArray(java.lang.Class<?> elementType)
MemoryModelnewEmptyArray(elementType, n), where
n is some little value.
Example of usage:
MutableFloatArray a = (MutableFloatArray)memoryModel.newEmptyArray(float.class);
newEmptyArray in interface MemoryModelelementType - the type of array elements.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newArray(Class, long)
public abstract MutableArray newEmptyArray(java.lang.Class<?> elementType,
long initialCapacity)
MemoryModelThe 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);
newEmptyArray in interface MemoryModelelementType - the type of array elements.initialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newArray(Class, long)
public abstract MutableArray newArray(java.lang.Class<?> elementType,
long initialLength)
MemoryModelThis method is equivalent to the following call:
newEmptyArray(elementType, initialLength).length(initialLength).trim().
newArray in interface MemoryModelelementType - the type of array elements.initialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyArray(Class, long),
MemoryModel.newUnresizableArray(Class, long)
public abstract UpdatableArray newUnresizableArray(java.lang.Class<?> elementType,
long length)
MemoryModelThe 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.
newUnresizableArray in interface MemoryModelelementType - the type of array elements.length - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newArray(Class, long)public MutableArray newArray(Array array)
MemoryModelnewArray(array.elementType(), array.length()).
newArray in interface MemoryModelarray - the pattern array.MemoryModel.isElementTypeSupported(Class)public UpdatableArray newUnresizableArray(Array array)
MemoryModelnewUnresizableArray(array.elementType(), array.length()).
newUnresizableArray in interface MemoryModelarray - the pattern array.MemoryModel.isElementTypeSupported(Class)public MutableBitArray newEmptyBitArray()
MemoryModelnewEmptyArray(boolean.class).
Example of usage:
MutableBitArray a = memoryModel.newEmptyBitArray();
newEmptyBitArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newBitArray(long)public MutableBitArray newEmptyBitArray(long initialCapacity)
MemoryModelnewEmptyArray(boolean.class, initialCapacity).
Example of usage:
MutableBitArray a = memoryModel.newEmptyBitArray(10000);
newEmptyBitArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newBitArray(long)public MutableBitArray newBitArray(long initialLength)
MemoryModelnewArray(boolean.class, initialLength).
newBitArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyBitArray(long)public UpdatableBitArray newUnresizableBitArray(long initialLength)
MemoryModelnewUnresizableArray(boolean.class, initialLength).
newUnresizableBitArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyBitArray(long)public MutableCharArray newEmptyCharArray()
MemoryModelnewEmptyArray(char.class).
Example of usage:
MutableCharArray a = memoryModel.newEmptyCharArray();
newEmptyCharArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newCharArray(long)public MutableCharArray newEmptyCharArray(long initialCapacity)
MemoryModelnewEmptyArray(char.class, initialCapacity).
Example of usage:
MutableCharArray a = memoryModel.newEmptyCharArray(10000);
newEmptyCharArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newCharArray(long)public MutableCharArray newCharArray(long initialLength)
MemoryModelnewArray(char.class, initialLength).
newCharArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyCharArray(long)public UpdatableCharArray newUnresizableCharArray(long initialLength)
MemoryModelnewUnresizableArray(char.class, initialLength).
newUnresizableCharArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyCharArray(long)public MutableByteArray newEmptyByteArray()
MemoryModelnewEmptyArray(byte.class).
Example of usage:
MutableByteArray a = memoryModel.newEmptyByteArray();
newEmptyByteArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newByteArray(long)public MutableByteArray newEmptyByteArray(long initialCapacity)
MemoryModelnewEmptyArray(byte.class, initialCapacity).
Example of usage:
MutableByteArray a = memoryModel.newEmptyByteArray(10000);
newEmptyByteArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newByteArray(long)public MutableByteArray newByteArray(long initialLength)
MemoryModelnewArray(byte.class, initialLength).
newByteArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyByteArray(long)public UpdatableByteArray newUnresizableByteArray(long initialLength)
MemoryModelnewUnresizableArray(byte.class, initialLength).
newUnresizableByteArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyByteArray(long)public MutableShortArray newEmptyShortArray()
MemoryModelnewEmptyArray(short.class).
Example of usage:
MutableShortArray a = memoryModel.newEmptyShortArray();
newEmptyShortArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newShortArray(long)public MutableShortArray newEmptyShortArray(long initialCapacity)
MemoryModelnewEmptyArray(short.class, initialCapacity).
Example of usage:
MutableShortArray a = memoryModel.newEmptyShortArray(10000);
newEmptyShortArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newShortArray(long)public MutableShortArray newShortArray(long initialLength)
MemoryModelnewArray(short.class, initialLength).
newShortArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyShortArray(long)public UpdatableShortArray newUnresizableShortArray(long initialLength)
MemoryModelnewUnresizableArray(short.class, initialLength).
newUnresizableShortArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyShortArray(long)public MutableIntArray newEmptyIntArray()
MemoryModelnewEmptyArray(int.class).
Example of usage:
MutableIntArray a = memoryModel.newEmptyIntArray();
newEmptyIntArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newIntArray(long)public MutableIntArray newEmptyIntArray(long initialCapacity)
MemoryModelnewEmptyArray(int.class, initialCapacity).
Example of usage:
MutableIntArray a = memoryModel.newEmptyIntArray(10000);
newEmptyIntArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newIntArray(long)public MutableIntArray newIntArray(long initialLength)
MemoryModelnewArray(int.class, initialLength).
newIntArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyIntArray(long)public UpdatableIntArray newUnresizableIntArray(long initialLength)
MemoryModelnewUnresizableArray(int.class, initialLength).
newUnresizableIntArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyIntArray(long)public MutableLongArray newEmptyLongArray()
MemoryModelnewEmptyArray(long.class).
Example of usage:
MutableLongArray a = memoryModel.newEmptyLongArray();
newEmptyLongArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newLongArray(long)public MutableLongArray newEmptyLongArray(long initialCapacity)
MemoryModelnewEmptyArray(long.class, initialCapacity).
Example of usage:
MutableLongArray a = memoryModel.newEmptyLongArray(10000);
newEmptyLongArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newLongArray(long)public MutableLongArray newLongArray(long initialLength)
MemoryModelnewArray(long.class, initialLength).
newLongArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyLongArray(long)public UpdatableLongArray newUnresizableLongArray(long initialLength)
MemoryModelnewUnresizableArray(long.class, initialLength).
newUnresizableLongArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyLongArray(long)public MutableFloatArray newEmptyFloatArray()
MemoryModelnewEmptyArray(float.class).
Example of usage:
MutableFloatArray a = memoryModel.newEmptyFloatArray();
newEmptyFloatArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newFloatArray(long)public MutableFloatArray newEmptyFloatArray(long initialCapacity)
MemoryModelnewEmptyArray(float.class, initialCapacity).
Example of usage:
MutableFloatArray a = memoryModel.newEmptyFloatArray(10000);
newEmptyFloatArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newFloatArray(long)public MutableFloatArray newFloatArray(long initialLength)
MemoryModelnewArray(float.class, initialLength).
newFloatArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyFloatArray(long)public UpdatableFloatArray newUnresizableFloatArray(long initialLength)
MemoryModelnewUnresizableArray(float.class, initialLength).
newUnresizableFloatArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyFloatArray(long)public MutableDoubleArray newEmptyDoubleArray()
MemoryModelnewEmptyArray(double.class).
Example of usage:
MutableDoubleArray a = memoryModel.newEmptyDoubleArray();
newEmptyDoubleArray in interface MemoryModelMemoryModel.isElementTypeSupported(Class),
MemoryModel.newDoubleArray(long)public MutableDoubleArray newEmptyDoubleArray(long initialCapacity)
MemoryModelnewEmptyArray(double.class, initialCapacity).
Example of usage:
MutableDoubleArray a = memoryModel.newEmptyDoubleArray(10000);
newEmptyDoubleArray in interface MemoryModelinitialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newDoubleArray(long)public MutableDoubleArray newDoubleArray(long initialLength)
MemoryModelnewArray(double.class, initialLength).
newDoubleArray in interface MemoryModelinitialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyDoubleArray(long)public UpdatableDoubleArray newUnresizableDoubleArray(long initialLength)
MemoryModelnewUnresizableArray(double.class, initialLength).
newUnresizableDoubleArray in interface MemoryModelinitialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyDoubleArray(long)public <E> MutableObjectArray<E> newEmptyObjectArray(java.lang.Class<E> elementType)
MemoryModelnewEmptyArray(elementType).
Example of usage:
MutableObjectArray<String> a = memoryModel.<String>newEmptyObjectArray(Class elementType);
newEmptyObjectArray in interface MemoryModelelementType - the type of array elements.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newObjectArray(Class elementType, long)
public <E> MutableObjectArray<E> newEmptyObjectArray(java.lang.Class<E> elementType,
long initialCapacity)
MemoryModelnewEmptyArray(elementType, initialCapacity).
Example of usage:
MutableObjectArray<String> a = memoryModel.<String>newEmptyObjectArray(10000);
newEmptyObjectArray in interface MemoryModelelementType - the type of array elements.initialCapacity - the initial capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newObjectArray(Class elementType, long)
public <E> MutableObjectArray<E> newObjectArray(java.lang.Class<E> elementType,
long initialLength)
MemoryModelnewArray(elementType, initialLength).
newObjectArray in interface MemoryModelelementType - the type of array elements.initialLength - the initial length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyObjectArray(Class elementType, long)
public <E> UpdatableObjectArray<E> newUnresizableObjectArray(java.lang.Class<E> elementType,
long initialLength)
MemoryModelnewUnresizableArray(elementType, initialLength).
newUnresizableObjectArray in interface MemoryModelelementType - the type of array elements.initialLength - the length and capacity of the array.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newEmptyObjectArray(Class elementType, long)public MutableArray newLazyCopy(Array 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);
newLazyCopy in interface MemoryModelarray - the source array.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.public UpdatableArray newUnresizableLazyCopy(Array 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);
newUnresizableLazyCopy in interface MemoryModelarray - the source array.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.
public <T extends UpdatableArray> Matrix<T> newMatrix(java.lang.Class<T> arraySupertype,
java.lang.Class<?> elementType,
long... dim)
newMatrix in interface MemoryModelarraySupertype - 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.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.Matrix,
MemoryModel.isElementTypeSupported(Class),
MemoryModel.newArray(Class, long),
MemoryModel.newMatrix(Class, Matrix),
Matrices.matrix(Array, long...),
Matrices.checkNewMatrixType(Class, Class)
public <T extends UpdatableArray> Matrix<T> newMatrix(long maxSizeAllocatedInJavaMemory,
java.lang.Class<T> arraySupertype,
java.lang.Class<?> elementType,
long... dim)
newMatrix in interface MemoryModelmaxSizeAllocatedInJavaMemory - 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.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.
public <T extends UpdatableArray> Matrix<T> newMatrix(java.lang.Class<T> arraySupertype,
Matrix<?> matrix)
MemoryModelnewMatrix(arraySupertype, matrix.elementType(), matrix.dimensions()).
newMatrix in interface MemoryModelarraySupertype - 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.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newStructuredMatrix(Class, Matrix),
Matrix
public <T extends UpdatableArray> Matrix<T> newStructuredMatrix(java.lang.Class<T> arraySupertype,
Matrix<?> matrix)
MemoryModelnewMatrix(arraySupertype, matrix).structureLike(matrix).
newStructuredMatrix in interface MemoryModelarraySupertype - 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.MemoryModel.isElementTypeSupported(Class),
Matrixpublic Matrix<UpdatableBitArray> newBitMatrix(long... dim)
MemoryModelnewMatrix(UpdatableBitArray.class, boolean.class, dim).
Example of usage:
Matrix<UpdatableBitArray> m = memoryModel.newBitMatrix(100, 100);
newBitMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newBitArray(long),
Matrices.matrix(Array, long...),
Matrixpublic Matrix<UpdatableCharArray> newCharMatrix(long... dim)
MemoryModelnewMatrix(UpdatableCharArray.class, char.class, dim).
Example of usage:
Matrix<UpdatableCharArray> m = memoryModel.newCharMatrix(100, 100);
newCharMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newCharArray(long),
Matrices.matrix(Array, long...),
Matrixpublic Matrix<UpdatableByteArray> newByteMatrix(long... dim)
MemoryModelnewMatrix(UpdatableByteArray.class, byte.class, dim).
Example of usage:
Matrix<UpdatableByteArray> m = memoryModel.newByteMatrix(100, 100);
newByteMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newByteArray(long),
Matrices.matrix(Array, long...),
Matrixpublic Matrix<UpdatableShortArray> newShortMatrix(long... dim)
MemoryModelnewMatrix(UpdatableShortArray.class, short.class, dim).
Example of usage:
Matrix<UpdatableShortArray> m = memoryModel.newShortMatrix(100, 100);
newShortMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newShortArray(long),
Matrices.matrix(Array, long...),
Matrixpublic Matrix<UpdatableIntArray> newIntMatrix(long... dim)
MemoryModelnewMatrix(UpdatableIntArray.class, int.class, dim).
Example of usage:
Matrix<UpdatableIntArray> m = memoryModel.newIntMatrix(100, 100);
newIntMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newIntArray(long),
Matrices.matrix(Array, long...),
Matrixpublic Matrix<UpdatableLongArray> newLongMatrix(long... dim)
MemoryModelnewMatrix(UpdatableLongArray.class, long.class, dim).
Example of usage:
Matrix<UpdatableLongArray> m = memoryModel.newLongMatrix(100, 100);
newLongMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newLongArray(long),
Matrices.matrix(Array, long...),
Matrixpublic Matrix<UpdatableFloatArray> newFloatMatrix(long... dim)
MemoryModelnewMatrix(UpdatableFloatArray.class, float.class, dim).
Example of usage:
Matrix<UpdatableFloatArray> m = memoryModel.newFloatMatrix(100, 100);
newFloatMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newFloatArray(long),
Matrices.matrix(Array, long...),
Matrixpublic Matrix<UpdatableDoubleArray> newDoubleMatrix(long... dim)
MemoryModelnewMatrix(UpdatableDoubleArray.class, double.class, dim).
Example of usage:
Matrix<UpdatableDoubleArray> m = memoryModel.newDoubleMatrix(100, 100);
newDoubleMatrix in interface MemoryModeldim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newDoubleArray(long),
Matrices.matrix(Array, long...),
Matrix
public <E> Matrix<UpdatableObjectArray<E>> newObjectMatrix(java.lang.Class<E> elementType,
long... dim)
MemoryModelnewMatrix(UpdatableObjectArray.class, elementType, dim).
Example of usage:
Matrix<UpdatableObjectArray<String>> m = memoryModel.newObjectMatrix(String.class, 100, 100);
newObjectMatrix in interface MemoryModelelementType - the type of matrix elements.dim - the dimensions of the matrix.MemoryModel.isElementTypeSupported(Class),
MemoryModel.newObjectArray(Class, long),
Matrices.matrix(Array, long...),
Matrix
public <T extends UpdatableArray> Matrix<T> newLazyCopy(java.lang.Class<T> arraySupertype,
Matrix<?> matrix)
MemoryModelmatrix(newUnresizableLazyCopy(matrix.array())).cast(arraySupertype).
newLazyCopy in interface MemoryModelarraySupertype - 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.
public UpdatableArray valueOf(java.lang.Object array,
int offset,
int count)
MemoryModelThe 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()).
valueOf in interface MemoryModelarray - 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.public UpdatableArray valueOf(java.lang.Object array)
MemoryModelThe 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.
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableBitArray valueOf(boolean[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableBitArray valueOf(boolean[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableCharArray valueOf(char[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableCharArray valueOf(char[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableByteArray valueOf(byte[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableByteArray valueOf(byte[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableShortArray valueOf(short[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableShortArray valueOf(short[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableIntArray valueOf(int[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableIntArray valueOf(int[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableLongArray valueOf(long[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableLongArray valueOf(long[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableFloatArray valueOf(float[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableFloatArray valueOf(float[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public UpdatableDoubleArray valueOf(double[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public UpdatableDoubleArray valueOf(double[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.
public <E> UpdatableObjectArray<E> valueOf(E[] array,
int offset,
int count)
MemoryModelvalueOf((Object)array, offset, count).
valueOf in interface MemoryModelarray - 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.public <E> UpdatableObjectArray<E> valueOf(E[] array)
MemoryModelvalueOf((Object)array).
valueOf in interface MemoryModelarray - the source Java array with elements of constructed AlgART array.public abstract boolean isElementTypeSupported(java.lang.Class<?> elementType)
MemoryModelUnsupportedElementTypeException.
The result is not defined for void.class.
isElementTypeSupported in interface MemoryModelelementType - the type of array elements.public abstract boolean areAllPrimitiveElementTypesSupported()
MemoryModel
areAllPrimitiveElementTypesSupported in interface MemoryModelMemoryModel.isElementTypeSupported(Class)public abstract boolean areAllElementTypesSupported()
MemoryModelSimpleMemoryModel.
areAllElementTypesSupported in interface MemoryModelMemoryModel.isElementTypeSupported(Class)public abstract long maxSupportedLength(java.lang.Class<?> elementType)
MemoryModelMemoryModel.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.
maxSupportedLength in interface MemoryModelelementType - the type of array elements.public abstract boolean isCreatedBy(Array array)
MemoryModelFor 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.
isCreatedBy in interface MemoryModelarray - the AlgART array (may be null, than the method returns false).
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||