public interface IntArrayValues extends Closeable
Implementations may store the array in different formats or mediums. For example, the array could be stored in binary format or text format, in memory or on disk.
The getValueAt and getVolatileValueAt methods retrieve the int value at a specified index. The difference between these methods is that getVolatileValueAt uses volatile semantics, meaning it includes a memory barrier which ensures that subsequent reads and writes are not reordered beyond this point.
The setValueAt and setOrderedValueAt methods set the int value at a specified index. The difference between these methods is that setOrderedValueAt uses ordered semantics, meaning it includes a memory barrier which ensures that previous writes are not reordered beyond this point.
The compareAndSet method atomically sets the value at a specified index to the given updated value if the current value equals the expected value.
The bindValueAt method binds an IntValue to a specified index in the array.
BooleanValue
,
ByteValue
,
CharValue
,
DoubleValue
,
FloatValue
,
IntValue
,
LongValue
,
ShortValue
,
StringValue
,
LongArrayValues
,
IntArrayValues
,
UnsetLongValue
Modifier and Type | Method and Description |
---|---|
void |
bindValueAt(long index,
IntValue value)
Binds an IntValue to a specified index in the array.
|
boolean |
compareAndSet(long index,
int expected,
int value)
Atomically sets the value at a specified index to the given updated value if the current value equals the expected value.
|
long |
getCapacity()
Retrieves the capacity of the array.
|
long |
getUsed()
Retrieves the number of used elements in the array.
|
int |
getValueAt(long index)
Retrieves the int value at a specified index.
|
int |
getVolatileValueAt(long index)
Retrieves the int value at a specified index using volatile semantics.
|
boolean |
isNull()
Checks if the array is null.
|
void |
reset()
Resets the array, clearing all values.
|
void |
setMaxUsed(long usedAtLeast)
Sets the maximum number of used elements in the array.
|
void |
setOrderedValueAt(long index,
int value)
Sets the int value at a specified index using ordered semantics.
|
void |
setValueAt(long index,
int value)
Sets the int value at a specified index.
|
long |
sizeInBytes(long capacity)
Calculates the size in bytes of an array with the specified capacity.
|
close, closeQuietly, closeQuietly
isClosed, isClosing
long getCapacity() throws IllegalStateException
IllegalStateException
- if the array is closedlong getUsed() throws IllegalStateException, BufferUnderflowException
IllegalStateException
- if the array is closedBufferUnderflowException
- if the array is emptyvoid setMaxUsed(long usedAtLeast) throws IllegalStateException, BufferUnderflowException
usedAtLeast
- the minimum number of used elements in the arrayIllegalStateException
- if the array is closedBufferUnderflowException
- if the array is emptyint getValueAt(long index) throws IllegalStateException, BufferUnderflowException
index
- the index of the int value to retrieveIllegalStateException
- if the array is closedBufferUnderflowException
- if the index is out of boundsvoid setValueAt(long index, int value) throws IllegalStateException, BufferOverflowException
index
- the index at which to set the int valuevalue
- the int value to setIllegalStateException
- if the array is closedBufferOverflowException
- if the index is out of boundsint getVolatileValueAt(long index) throws IllegalStateException, BufferUnderflowException
index
- the index of the int value to retrieveIllegalStateException
- if the array is closedBufferUnderflowException
- if the index is out of boundsvoid setOrderedValueAt(long index, int value) throws IllegalStateException, BufferOverflowException
index
- the index at which to set the int valuevalue
- the int value to setIllegalStateException
- if the array is closedBufferOverflowException
- if the index is out of boundsboolean compareAndSet(long index, int expected, int value) throws IllegalStateException, BufferOverflowException
index
- the index at which to set the int valueexpected
- the expected current valuevalue
- the new valueIllegalStateException
- if the array is closedBufferOverflowException
- if the index is out of boundsvoid bindValueAt(long index, IntValue value) throws IllegalStateException, BufferOverflowException, IllegalArgumentException
index
- the index at which to bind the IntValuevalue
- the IntValue to bindIllegalStateException
- if the array is closedBufferOverflowException
- if the index is out of boundsIllegalArgumentException
- if the value is not validlong sizeInBytes(long capacity) throws IllegalStateException
capacity
- the capacity of the arrayIllegalStateException
- if the array is closedboolean isNull() throws IllegalStateException
IllegalStateException
- if the array is closedvoid reset() throws IllegalStateException
IllegalStateException
- if the array is closedCopyright © 2023. All rights reserved.