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| 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, closeQuietlyisClosed, isClosinglong getCapacity()
throws IllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionlong getUsed()
throws IllegalStateException,
BufferUnderflowException
BufferUnderflowException - If the array is emptyClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid setMaxUsed(long usedAtLeast)
throws IllegalStateException,
BufferUnderflowException
usedAtLeast - the minimum number of used elements in the arrayBufferUnderflowException - If the array is emptyClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionint getValueAt(long index)
throws IllegalStateException,
BufferUnderflowException
index - the index of the int value to retrieveBufferUnderflowException - If the index is out of boundsClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid setValueAt(long index,
int value)
throws IllegalStateException,
BufferOverflowException
index - the index at which to set the int valuevalue - the int value to setBufferOverflowException - If the index is out of boundsClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionint getVolatileValueAt(long index)
throws IllegalStateException,
BufferUnderflowException
index - the index of the int value to retrieveBufferUnderflowException - If the index is out of boundsClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid setOrderedValueAt(long index,
int value)
throws IllegalStateException,
BufferOverflowException
index - the index at which to set the int valuevalue - the int value to setBufferOverflowException - If the index is out of boundsClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionboolean 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 valueBufferOverflowException - If the index is out of boundsClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid bindValueAt(long index,
IntValue value)
throws IllegalStateException,
BufferOverflowException,
IllegalArgumentException
index - the index at which to bind the IntValuevalue - the IntValue to bindBufferOverflowException - If the index is out of boundsIllegalArgumentException - If the value is not validClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionlong sizeInBytes(long capacity)
throws IllegalStateException
capacity - the capacity of the arrayClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionboolean isNull()
throws IllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid reset()
throws IllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionCopyright © 2024. All rights reserved.