Package org.apfloat.internal
Class IntMemoryDataStorage
java.lang.Object
org.apfloat.spi.DataStorage
org.apfloat.internal.IntMemoryDataStorage
- All Implemented Interfaces:
Serializable
Memory based data storage implementation for the
int
element type.- Version:
- 1.9.0
- Author:
- Mikko Tommila
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apfloat.spi.DataStorage
DataStorage.AbstractIterator, DataStorage.Iterator -
Field Summary
Fields inherited from class org.apfloat.spi.DataStorage
READ, READ_WRITE, WRITE -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor.protectedIntMemoryDataStorage(IntMemoryDataStorage intMemoryDataStorage, long offset, long length)Subsequence constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidimplCopyFrom(DataStorage dataStorage, long size)Copies the specified number of elements from another data storage to this data storage.protected ArrayAccessimplGetArray(int mode, int startColumn, int columns, int rows)Maps a block of data to a memory array when the data is treated as a matrix.protected ArrayAccessimplGetArray(int mode, long offset, int length)Gets an array access to the data of this data storage when it is treated as a linear block.protected longReturn the size of the whole data storage, not including sub-sequence settings.protected ArrayAccessimplGetTransposedArray(int mode, int startColumn, int columns, int rows)Maps a transposed block of data to a memory array when the data is treated as a matrix.protected voidimplSetSize(long size)Sets the size of the data storage.protected DataStorageimplSubsequence(long offset, long length)Implementation of getting a subsequence of this data storage.booleanisCached()Is this object cached in memory.iterator(int mode, long startPosition, long endPosition)Constructs a new iterator.Methods inherited from class org.apfloat.spi.DataStorage
copyFrom, copyFrom, getArray, getArray, getOffset, getSize, getTransposedArray, isReadOnly, isSubsequenced, setReadOnly, setSize, subsequence
-
Constructor Details
-
IntMemoryDataStorage
public IntMemoryDataStorage()Default constructor. -
IntMemoryDataStorage
protected IntMemoryDataStorage(IntMemoryDataStorage intMemoryDataStorage, long offset, long length)Subsequence constructor.- Parameters:
intMemoryDataStorage- The originating data storage.offset- The subsequence starting position.length- The subsequence length.
-
-
Method Details
-
isCached
public boolean isCached()Description copied from class:DataStorageIs this object cached in memory.- Specified by:
isCachedin classDataStorage- Returns:
trueif this object is cached in memory,falseif not.
-
implSubsequence
Description copied from class:DataStorageImplementation of getting a subsequence of this data storage. The validity of the arguments of this method do not need to be checked.- Specified by:
implSubsequencein classDataStorage- Parameters:
offset- The subsequence starting position.length- The subsequence length.- Returns:
- Data storage that represents the specified part of this data storage.
- Throws:
ApfloatRuntimeException
-
implCopyFrom
Description copied from class:DataStorageCopies the specified number of elements from another data storage to this data storage. The validity of the arguments of this method do not need to be checked.- Specified by:
implCopyFromin classDataStorage- Parameters:
dataStorage- The data storage where the data should be copied from.size- The number of elements to be copied.- Throws:
ApfloatRuntimeException
-
implGetSize
protected long implGetSize()Description copied from class:DataStorageReturn the size of the whole data storage, not including sub-sequence settings.- Specified by:
implGetSizein classDataStorage- Returns:
- The size of the whole data storage, not including sub-sequence settings.
-
implSetSize
Description copied from class:DataStorageSets the size of the data storage. The validity of the arguments of this method do not need to be checked.- Specified by:
implSetSizein classDataStorage- Parameters:
size- The size of the data storage.- Throws:
ApfloatRuntimeException
-
implGetArray
protected ArrayAccess implGetArray(int mode, long offset, int length) throws ApfloatRuntimeExceptionDescription copied from class:DataStorageGets an array access to the data of this data storage when it is treated as a linear block. The validity of the arguments of this method do not need to be checked.- Specified by:
implGetArrayin classDataStorage- Parameters:
mode- Access mode for the array access:DataStorage.READ,DataStorage.WRITEor both.offset- Starting position of the array access in the data storage.length- Number of accessible elements in the array access.- Returns:
- The array access.
- Throws:
ApfloatRuntimeException
-
implGetArray
protected ArrayAccess implGetArray(int mode, int startColumn, int columns, int rows) throws ApfloatRuntimeExceptionDescription copied from class:DataStorageMaps a block of data to a memory array when the data is treated as a matrix. The validity of the arguments of this method do not need to be checked.- Specified by:
implGetArrayin classDataStorage- Parameters:
mode- Whether the array is prepared for reading, writing or both. The value should beDataStorage.READ,DataStorage.WRITEor a combination of these.startColumn- The starting column where data is read.columns- The number of columns of data to read.rows- The number of rows of data to read. This should be equivalent to n1, number of rows in the matrix.- Returns:
- Access to an array of size
columnsxrowscontaining the data. - Throws:
ApfloatRuntimeException
-
implGetTransposedArray
protected ArrayAccess implGetTransposedArray(int mode, int startColumn, int columns, int rows) throws ApfloatRuntimeExceptionDescription copied from class:DataStorageMaps a transposed block of data to a memory array when the data is treated as a matrix. The validity of the arguments of this method do not need to be checked.- Specified by:
implGetTransposedArrayin classDataStorage- Parameters:
mode- Whether the array is prepared for reading, writing or both. The value should beDataStorage.READ,DataStorage.WRITEor a combination of these.startColumn- The starting column where data is read.columns- The number of columns of data to read.rows- The number of rows of data to read. This should be equivalent to n1, number of rows in the matrix.- Returns:
- Access to an array of size
columnsxrowscontaining the transposed data. - Throws:
ApfloatRuntimeException
-
iterator
public DataStorage.Iterator iterator(int mode, long startPosition, long endPosition) throws IllegalArgumentException, IllegalStateException, ApfloatRuntimeExceptionDescription copied from class:DataStorageConstructs a new iterator. Elements can be iterated either in forward or in reverse order, depending on ifstartPositionis less than or greater thanendPosition, correspondingly.- Specified by:
iteratorin classDataStorage- Parameters:
mode- Access mode for iterator:DataStorage.READ,DataStorage.WRITEor both.startPosition- Starting position of iterator in the data set. For reverse access, the first element in the iterator isstartPosition - 1.endPosition- End position of iterator in the data set. For forward access, the last accessible element in the iterator isendPosition - 1.- Returns:
- An iterator.
- Throws:
IllegalArgumentException- If the requested area is out of bounds of the data storage.IllegalStateException- If write access is requested for a read-only data storage.ApfloatRuntimeException
-