public interface LongArrayValues 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 long 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 long 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 a LongValue 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,
LongValue value)
Binds a LongValue to a specified index in the array.
|
boolean |
compareAndSet(long index,
long expected,
long 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.
|
long |
getValueAt(long index)
Retrieves the long value at a specified index.
|
long |
getVolatileValueAt(long index)
Retrieves the long 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,
long value)
Sets the long value at a specified index using ordered semantics.
|
void |
setUsed(long used)
Sets the number of used elements in the array.
|
void |
setValueAt(long index,
long value)
Sets the long 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
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferUnderflowException - If the array is emptyIllegalStateExceptionvoid setUsed(long used)
throws IllegalStateException,
BufferUnderflowException
used - the number of used elements in the arrayClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferUnderflowException - If the array is emptyIllegalStateExceptionvoid setMaxUsed(long usedAtLeast)
throws IllegalStateException,
BufferUnderflowException
usedAtLeast - the minimum number of used elements in the arrayClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferUnderflowException - If the array is emptyIllegalStateExceptionlong getValueAt(long index)
throws IllegalStateException,
BufferUnderflowException
index - the index of the long value to retrieveClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferUnderflowException - If the index is out of boundsIllegalStateExceptionvoid setValueAt(long index,
long value)
throws IllegalStateException,
BufferOverflowException
index - the index at which to set the long valuevalue - the long value to setClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferOverflowException - If the index is out of boundsIllegalStateExceptionlong getVolatileValueAt(long index)
throws IllegalStateException,
BufferUnderflowException
index - the index of the long value to retrieveClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferUnderflowException - If the index is out of boundsIllegalStateExceptionvoid setOrderedValueAt(long index,
long value)
throws IllegalStateException,
BufferOverflowException
index - the index at which to set the long valuevalue - the long value to setClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferOverflowException - If the index is out of boundsIllegalStateExceptionboolean compareAndSet(long index,
long expected,
long value)
throws IllegalStateException,
BufferOverflowException
index - the index at which to set the long valueexpected - the expected current valuevalue - the new valueClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferOverflowException - If the index is out of boundsIllegalStateExceptionvoid bindValueAt(long index,
LongValue value)
throws IllegalStateException,
BufferOverflowException
index - the index at which to bind the LongValuevalue - the LongValue to bindClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayBufferOverflowException - If the index is out of boundsIllegalStateExceptionlong 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.