Class LongMemoryDataStorage.ReadWriteIterator
- java.lang.Object
-
- org.apfloat.spi.DataStorage.Iterator
-
- org.apfloat.spi.DataStorage.AbstractIterator
-
- org.apfloat.internal.LongMemoryDataStorage.ReadWriteIterator
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.AutoCloseable
- Direct Known Subclasses:
LongMemoryDataStorage.ReadOnlyIterator
,LongMemoryDataStorage.WriteOnlyIterator
- Enclosing class:
- LongMemoryDataStorage
private class LongMemoryDataStorage.ReadWriteIterator extends DataStorage.AbstractIterator
-
-
Field Summary
Fields Modifier and Type Field Description private long[]
data
private int
length
private int
position
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description protected
ReadWriteIterator(int mode, long startPosition, long endPosition)
ReadWriteIterator(long startPosition, long endPosition)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkLength()
Checks if the iterator is at the end yet.<T> T
get(java.lang.Class<T> type)
Gets the current element as a the specified element type.long
getLong()
Gets the current element as along
.boolean
hasNext()
Check ifnext()
can be called without going past the end of the sequence.void
next()
Advances the position in the stream by one element.<T> void
set(java.lang.Class<T> type, T value)
Sets the current element as the specified element type.void
setLong(long value)
Sets the current element as along
.-
Methods inherited from class org.apfloat.spi.DataStorage.AbstractIterator
checkGet, checkSet, getDouble, getFloat, getIncrement, getInt, getLength, getMode, getPosition, setDouble, setFloat, setInt
-
Methods inherited from class org.apfloat.spi.DataStorage.Iterator
close
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
data
private long[] data
-
position
private int position
-
length
private int length
-
-
Constructor Detail
-
ReadWriteIterator
public ReadWriteIterator(long startPosition, long endPosition) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, ApfloatRuntimeException
- Throws:
java.lang.IllegalArgumentException
java.lang.IllegalStateException
ApfloatRuntimeException
-
ReadWriteIterator
protected ReadWriteIterator(int mode, long startPosition, long endPosition) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, ApfloatRuntimeException
- Throws:
java.lang.IllegalArgumentException
java.lang.IllegalStateException
ApfloatRuntimeException
-
-
Method Detail
-
hasNext
public boolean hasNext()
Description copied from class:DataStorage.AbstractIterator
Check ifnext()
can be called without going past the end of the sequence. That is, ifnext()
can be called without deliberately causing an exception.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:
hasNext
in classDataStorage.AbstractIterator
- Returns:
true
ifDataStorage.AbstractIterator.next()
can be called, otherwisefalse
.
-
next
public void next() throws java.lang.IllegalStateException
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:
java.lang.IllegalStateException
- If the iterator has been iterated to the end already.
-
getLong
public long getLong() throws java.lang.IllegalStateException
Description copied from class:DataStorage.Iterator
Gets the current element as along
.The default implementation calls
DataStorage.Iterator.get(Class)
with argumentLong.TYPE
.- Overrides:
getLong
in classDataStorage.AbstractIterator
- Returns:
- The current element as a
long
. - Throws:
java.lang.IllegalStateException
- If the iterator is at the end.
-
setLong
public void setLong(long value) throws java.lang.IllegalStateException
Description copied from class:DataStorage.Iterator
Sets the current element as along
.The default implementation calls
DataStorage.Iterator.set(Class,Object)
with first argumentLong.TYPE
.- Overrides:
setLong
in classDataStorage.AbstractIterator
- Parameters:
value
- The value to be set to the current element as along
.- Throws:
java.lang.IllegalStateException
- If the iterator is at the end.
-
get
public <T> T get(java.lang.Class<T> type) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException
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:
java.lang.UnsupportedOperationException
- If the element type of the data storage can't be converted to the specified type.java.lang.IllegalStateException
- If the iterator is at the end.
-
set
public <T> void set(java.lang.Class<T> type, T value) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException, java.lang.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:
java.lang.UnsupportedOperationException
- If the element type of the data storage can't be converted to the specified type.java.lang.IllegalArgumentException
- If the value is not of the specified type.java.lang.IllegalStateException
- If the iterator is at the end.
-
checkLength
protected void checkLength() throws java.lang.IllegalStateException
Description copied from class:DataStorage.AbstractIterator
Checks if the iterator is at the end yet.- Overrides:
checkLength
in classDataStorage.AbstractIterator
- Throws:
java.lang.IllegalStateException
- If the iterator is at end.
-
-