Class SignalMemoryModel
- All Implemented Interfaces:
MemoryModel
The degenerate memory model that does not allow to create any AlgART arrays.
Any attempt to create an array by methods of this class leads to
UnsupportedElementTypeException
(or, maybe, NullPointerException,
IllegalArgumentException or ClassCastException,
if the comments to the method require this).
This class may be useful to detect a bug, when some method have a MemoryModel
argument,
but you are sure that this argument must not be used for creating any AlgART arrays.
This class is immutable and thread-safe:
there are no ways to modify settings of its instance returned by getInstance()
method.
Moreover, it is a singleton: getInstance()
always returns the same object.
- Author:
- Daniel Alievsky
-
Method Summary
Modifier and TypeMethodDescriptionboolean
This implementation always returns false.boolean
This implementation always returns false.static SignalMemoryModel
Returns an instance of this memory model.boolean
isCreatedBy
(Array array) This implementation always returns false.boolean
isElementTypeSupported
(Class<?> elementType) This implementation always returns false.long
maxSupportedLength
(Class<?> elementType) This implementation always returns -1.Allocates a zero-filled resizable array with the specified element type and initial length.newEmptyArray
(Class<?> elementType) Allocates an empty resizable array with the specified element type and a little initial capacity.newEmptyArray
(Class<?> elementType, long initialCapacity) Allocates an empty resizable array with the specified element type and initial capacity.newUnresizableArray
(Class<?> elementType, long length) Allocates a zero-filled unresizable array with the specified element type and length.Methods inherited from class net.algart.arrays.AbstractMemoryModel
newArray, newBitArray, newBitMatrix, newByteArray, newByteMatrix, newCharArray, newCharMatrix, newDoubleArray, newDoubleMatrix, newEmptyBitArray, newEmptyBitArray, newEmptyByteArray, newEmptyByteArray, newEmptyCharArray, newEmptyCharArray, newEmptyDoubleArray, newEmptyDoubleArray, newEmptyFloatArray, newEmptyFloatArray, newEmptyIntArray, newEmptyIntArray, newEmptyLongArray, newEmptyLongArray, newEmptyObjectArray, newEmptyObjectArray, newEmptyShortArray, newEmptyShortArray, newFloatArray, newFloatMatrix, newIntArray, newIntMatrix, newLazyCopy, newLazyCopy, newLongArray, newLongMatrix, newMatrix, newMatrix, newMatrix, newObjectArray, newObjectMatrix, newShortArray, newShortMatrix, newStructuredMatrix, newUnresizableArray, newUnresizableBitArray, newUnresizableByteArray, newUnresizableCharArray, newUnresizableDoubleArray, newUnresizableFloatArray, newUnresizableIntArray, newUnresizableLazyCopy, newUnresizableLongArray, newUnresizableObjectArray, newUnresizableShortArray, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf
-
Method Details
-
getInstance
Returns an instance of this memory model.- Returns:
- an instance of this memory model.
-
newEmptyArray
Description copied from interface:MemoryModel
Allocates an empty resizable array with the specified element type and a little initial capacity. It is equivalent tonewEmptyArray(elementType, n)
, where n is some little value.Example of usage:
MutableFloatArray a = (MutableFloatArray)memoryModel.newEmptyArray(float.class);
- Specified by:
newEmptyArray
in interfaceMemoryModel
- Specified by:
newEmptyArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.- Returns:
- created AlgART array.
- See Also:
-
newEmptyArray
Description copied from interface:MemoryModel
Allocates an empty resizable array with the specified element type and initial capacity.The element type can be either usual object class (as String.class), or one of the primitive types: boolean.class, byte.class, short.class, int.class, long.class, float.class, double.class, char.class. The element type cannot be void.class.
In a case of primitive types, the created array will implement the corresponding interface
BitArray
,ByteArray
,ShortArray
,IntArray
,LongArray
,FloatArray
,DoubleArray
orCharArray
. In this case, the created array (unlike standard ArrayList) will occupy the same amount of memory as the Java array boolean[initialCapacity], byte[initialCapacity], etc.In a case of non-primitive types (Object inheritors), the created array will implement the
MutableObjectArray
interface.Some element type may be not supported by this memory model. For example, some memory models may support only primitive types, or only one concrete type. In such a case,
UnsupportedElementTypeException
will be thrown.Some too large array capacities may be not supported by this memory model. For example,
SimpleMemoryModel
does not support arrays larger than 0x7FFFFFFF (Integer.MAX_VALUE) elements.Example of usage:
MutableFloatArray a = (MutableFloatArray)memoryModel.newEmptyArray(float.class, 10000);
- Specified by:
newEmptyArray
in interfaceMemoryModel
- Specified by:
newEmptyArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.initialCapacity
- the initial capacity of the array.- Returns:
- created AlgART array.
- See Also:
-
newArray
Description copied from interface:MemoryModel
Allocates a zero-filled resizable array with the specified element type and initial length. The capacity of new array will be equal to its length.This method is equivalent to the following call:
newEmptyArray(elementType, initialLength)
.length(initialLength)
.trim()
.- Specified by:
newArray
in interfaceMemoryModel
- Specified by:
newArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.initialLength
- the initial length and capacity of the array.- Returns:
- created AlgART array.
- See Also:
-
newUnresizableArray
Description copied from interface:MemoryModel
Allocates a zero-filled unresizable array with the specified element type and length. The capacity of new array will be equal to its length.The analogous result may be obtained the following call:
newArray(elementType, length)
.asUnresizable()
. However, we don't recommend to use such code. If you are sure that you will not need to change the array length, please always use this method (ornewUnresizableBitArray
,newUnresizableBteArray
, etc.). In some memory models, creating resizable array with the given length may require much more resources that creating unresizable one. For example, in thelarge memory model
every resizable array is stored in the file consisting of integer number of blocks perDataFileModel.recommendedBankSize(true)
bytes.- Specified by:
newUnresizableArray
in interfaceMemoryModel
- Specified by:
newUnresizableArray
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.length
- the length and capacity of the array.- Returns:
- created unresizable AlgART array.
- See Also:
-
isElementTypeSupported
This implementation always returns false.- Specified by:
isElementTypeSupported
in interfaceMemoryModel
- Specified by:
isElementTypeSupported
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.- Returns:
- false always.
- Throws:
NullPointerException
- if elementType is null.
-
areAllPrimitiveElementTypesSupported
public boolean areAllPrimitiveElementTypesSupported()This implementation always returns false.- Specified by:
areAllPrimitiveElementTypesSupported
in interfaceMemoryModel
- Specified by:
areAllPrimitiveElementTypesSupported
in classAbstractMemoryModel
- Returns:
- false always.
- See Also:
-
areAllElementTypesSupported
public boolean areAllElementTypesSupported()This implementation always returns false.- Specified by:
areAllElementTypesSupported
in interfaceMemoryModel
- Specified by:
areAllElementTypesSupported
in classAbstractMemoryModel
- Returns:
- false always.
- See Also:
-
maxSupportedLength
This implementation always returns -1.- Specified by:
maxSupportedLength
in interfaceMemoryModel
- Specified by:
maxSupportedLength
in classAbstractMemoryModel
- Parameters:
elementType
- the type of array elements.- Returns:
- -1 always.
- Throws:
NullPointerException
- if elementType is null.
-
isCreatedBy
This implementation always returns false.- Specified by:
isCreatedBy
in interfaceMemoryModel
- Specified by:
isCreatedBy
in classAbstractMemoryModel
- Parameters:
array
- the AlgART array (may be null, than the method returns false).- Returns:
- false always.
-