Package org.apfloat.internal
Class IntDiskDataStorage.BlockIterator
java.lang.Object
org.apfloat.spi.DataStorage.Iterator
org.apfloat.spi.DataStorage.AbstractIterator
org.apfloat.internal.IntDiskDataStorage.BlockIterator
- All Implemented Interfaces:
Serializable
,AutoCloseable
- Enclosing class:
IntDiskDataStorage
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ArrayAccess
private int[]
private int
private int
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
close()
Closes the iterator.<T> T
Gets the current element as a the specified element type.int
getInt()
Gets the current element as anint
.void
next()
Advances the position in the stream by one element.<T> void
Sets the current element as the specified element type.void
setInt
(int value) Sets the current element as anint
.Methods inherited from class org.apfloat.spi.DataStorage.AbstractIterator
checkGet, checkLength, checkSet, getDouble, getFloat, getIncrement, getLength, getLong, getMode, getPosition, hasNext, setDouble, setFloat, setLong
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
arrayAccess
-
data
private int[] data -
offset
private int offset -
remaining
private int remaining
-
-
Constructor Details
-
BlockIterator
public BlockIterator(int mode, long startPosition, long endPosition) throws IllegalArgumentException, IllegalStateException, ApfloatRuntimeException
-
-
Method Details
-
next
Description copied from class:DataStorage.AbstractIterator
Advances the position in the stream by one element.Note: It is important that the iterator is iterated past the last element; that is
next()
is calledstartPosition - endPosition
times. Theget()
orset()
methods should not be called for the last element.- Overrides:
next
in classDataStorage.AbstractIterator
- Throws:
IllegalStateException
- If the iterator has been iterated to the end already.ApfloatRuntimeException
-
getInt
Description copied from class:DataStorage.Iterator
Gets the current element as anint
.The default implementation calls
DataStorage.Iterator.get(Class)
with argumentInteger.TYPE
.- Overrides:
getInt
in classDataStorage.AbstractIterator
- Returns:
- The current element as an
int
. - Throws:
IllegalStateException
- If the iterator is at the end.ApfloatRuntimeException
-
setInt
Description copied from class:DataStorage.Iterator
Sets the current element as anint
.The default implementation calls
DataStorage.Iterator.set(Class,Object)
with first argumentInteger.TYPE
.- Overrides:
setInt
in classDataStorage.AbstractIterator
- Parameters:
value
- The value to be set to the current element as anint
.- Throws:
IllegalStateException
- If the iterator is at the end.ApfloatRuntimeException
-
get
Description copied from class:DataStorage.Iterator
Gets the current element as a the specified element type.The default implementation always throws
UnsupportedOperationException
.- Overrides:
get
in classDataStorage.Iterator
- Type Parameters:
T
- The type of the element.- Parameters:
type
- The type of the element.- Returns:
- The current element as the specified type.
- Throws:
UnsupportedOperationException
- If the element type of the data storage can't be converted to the specified type.IllegalStateException
- If the iterator is at the end.
-
set
public <T> void set(Class<T> type, T value) throws UnsupportedOperationException, IllegalArgumentException, IllegalStateException Description copied from class:DataStorage.Iterator
Sets the current element as the specified element type.The default implementation always throws
UnsupportedOperationException
.- Overrides:
set
in classDataStorage.Iterator
- Type Parameters:
T
- The type of the element.- Parameters:
type
- The type of the element.value
- The value to be set to the current element as the specified type.- Throws:
UnsupportedOperationException
- If the element type of the data storage can't be converted to the specified type.IllegalArgumentException
- If the value is not of the specified type.IllegalStateException
- If the iterator is at the end.
-
close
Closes the iterator. This needs to be called only if the iterator is not iterated to the end.- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classDataStorage.Iterator
- Throws:
ApfloatRuntimeException
-
checkAvailable
- Throws:
ApfloatRuntimeException
-