-
- All Implemented Interfaces:
-
io.github.millibyte1.array64.Array64Iterator
,io.github.millibyte1.array64.LongIndexedIterator
,kotlin.collections.Iterator
public interface AtomicArray64Iterator<E extends Object> implements Array64Iterator<E>
An Array64Iterator which supports atomic operations such as compareAndSet.
-
-
Method Summary
Modifier and Type Method Description abstract E
next()
Returns the next element in the iteration. abstract E
previous()
Returns the previous element in the iteration. abstract Unit
set(E element)
Replaces the element at the current index (the last element returned by next or previous) with the specified element. abstract E
getAndSet(E new)
Sets the element at the current index to the given new value and returns the old value. abstract E
getAndSet(Function1<E, E> transform)
Sets the element at the current index to the value resulting from applying the given transform to the old value. abstract E
setAndGet(Function1<E, E> transform)
Sets the element at the current index to the resulting value from applying the given transform to the old value. abstract Boolean
compareAndSet(E new, E expected)
Sets the element at the current index to the given new value if the current value matches expected. abstract Boolean
compareAndSet(E new, Function2<E, E, Boolean> predicate)
Sets the element at the current index to the given new value if the provided predicate returns true when applied to the old and new values. abstract Unit
lazySet(E value)
Eventually sets the element at the given index to the given value. abstract Long
getIndex()
The current index of this iterator. -
Methods inherited from class io.github.millibyte1.array64.atomic.AtomicArray64Iterator
hasPrevious
-
Methods inherited from class io.github.millibyte1.array64.Array64Iterator
forEachRemaining, hasNext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getAndSet
abstract E getAndSet(E new)
Sets the element at the current index to the given new value and returns the old value. Atomic.
- Parameters:
new
- the value to set the element to
-
getAndSet
abstract E getAndSet(Function1<E, E> transform)
Sets the element at the current index to the value resulting from applying the given transform to the old value. Atomic.
- Parameters:
transform
- the pure (side effect-free) transform function to apply to the old value
-
setAndGet
abstract E setAndGet(Function1<E, E> transform)
Sets the element at the current index to the resulting value from applying the given transform to the old value. Atomic.
- Parameters:
transform
- the pure (side effect-free) transform function to apply to the old value
-
compareAndSet
abstract Boolean compareAndSet(E new, E expected)
Sets the element at the current index to the given new value if the current value matches expected. Atomic.
- Parameters:
new
- the value to set the element toexpected
- the expected value of the element
-
compareAndSet
abstract Boolean compareAndSet(E new, Function2<E, E, Boolean> predicate)
Sets the element at the current index to the given new value if the provided predicate returns true when applied to the old and new values.
- Parameters:
new
- the value to set the element topredicate
- the binary predicate to apply to the old and new values to decide whether to update
-
lazySet
abstract Unit lazySet(E value)
Eventually sets the element at the given index to the given value. Depending on the implementation, may immediately perform a volatile write.
- Parameters:
value
- the value to set the element to
-
-
-
-