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 TypeMethodDescriptionbooleanThis implementation always returns false.booleanThis implementation always returns false.static SignalMemoryModelReturns an instance of this memory model.booleanisCreatedBy(Array array) This implementation always returns false.booleanisElementTypeSupported(Class<?> elementType) This implementation always returns false.longmaxSupportedLength(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:MemoryModelAllocates 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:
newEmptyArrayin interfaceMemoryModel- Specified by:
newEmptyArrayin classAbstractMemoryModel- Parameters:
elementType- the type of array elements.- Returns:
- created AlgART array.
- See Also:
-
newEmptyArray
Description copied from interface:MemoryModelAllocates 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,DoubleArrayorCharArray. 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
MutableObjectArrayinterface.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,
UnsupportedElementTypeExceptionwill be thrown.Some too large array capacities may be not supported by this memory model. For example,
SimpleMemoryModeldoes not support arrays larger than 0x7FFFFFFF (Integer.MAX_VALUE) elements.Example of usage:
MutableFloatArray a = (MutableFloatArray)memoryModel.newEmptyArray(float.class, 10000);
- Specified by:
newEmptyArrayin interfaceMemoryModel- Specified by:
newEmptyArrayin 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:MemoryModelAllocates 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:
newArrayin interfaceMemoryModel- Specified by:
newArrayin 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:MemoryModelAllocates 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 modelevery resizable array is stored in the file consisting of integer number of blocks perDataFileModel.recommendedBankSize(true)bytes.- Specified by:
newUnresizableArrayin interfaceMemoryModel- Specified by:
newUnresizableArrayin 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:
isElementTypeSupportedin interfaceMemoryModel- Specified by:
isElementTypeSupportedin 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:
areAllPrimitiveElementTypesSupportedin interfaceMemoryModel- Specified by:
areAllPrimitiveElementTypesSupportedin classAbstractMemoryModel- Returns:
- false always.
- See Also:
-
areAllElementTypesSupported
public boolean areAllElementTypesSupported()This implementation always returns false.- Specified by:
areAllElementTypesSupportedin interfaceMemoryModel- Specified by:
areAllElementTypesSupportedin classAbstractMemoryModel- Returns:
- false always.
- See Also:
-
maxSupportedLength
This implementation always returns -1.- Specified by:
maxSupportedLengthin interfaceMemoryModel- Specified by:
maxSupportedLengthin 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:
isCreatedByin interfaceMemoryModel- Specified by:
isCreatedByin classAbstractMemoryModel- Parameters:
array- the AlgART array (may be null, than the method returns false).- Returns:
- false always.
-