/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
/** * Eventually sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value * @since 1.6 */ public final void lazySet(int i, int newValue) { unsafe.putOrderedInt(array, checkedByteOffset(i), newValue); }
/** * Gets the current value at position {@code i}. * * @param i the index * @return the current value */ public final int get(int i) { return getRaw(checkedByteOffset(i)); }
/** * Atomically sets the element at position {@code i} to the given * updated value if the current value {@code ==} the expected value. * * @param i the index * @param expect the expected value * @param update the new value * @return true if successful. False return indicates that * the actual value was not equal to the expected value. */ public final boolean compareAndSet(int i, int expect, int update) { return compareAndSetRaw(checkedByteOffset(i), expect, update); }
/** * Atomically adds the given value to the element at index {@code i}. * * @param i the index * @param delta the value to add * @return the previous value */ public final int getAndAdd(int i, int delta) { long offset = checkedByteOffset(i); while (true) { int current = getRaw(offset); if (compareAndSetRaw(offset, current, current + delta)) return current; } }
/** * Atomically sets the element at position {@code i} to the given * value and returns the old value. * * @param i the index * @param newValue the new value * @return the previous value */ public final int getAndSet(int i, int newValue) { long offset = checkedByteOffset(i); while (true) { int current = getRaw(offset); if (compareAndSetRaw(offset, current, newValue)) return current; } }
/** * Atomically adds the given value to the element at index {@code i}. * * @param i the index * @param delta the value to add * @return the updated value */ public final int addAndGet(int i, int delta) { long offset = checkedByteOffset(i); while (true) { int current = getRaw(offset); int next = current + delta; if (compareAndSetRaw(offset, current, next)) return next; } }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
/** * Gets the current value at position {@code i}. * * @param i the index * @return the current value */ public final int get(int i) { return getRaw(checkedByteOffset(i)); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
/** * Gets the current value at position {@code i}. * * @param i the index * @return the current value */ public final int get(int i) { return getRaw(checkedByteOffset(i)); }
/** * Eventually sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value * @since 1.6 */ public final void lazySet(int i, int newValue) { unsafe.putOrderedInt(array, checkedByteOffset(i), newValue); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
/** * Eventually sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value * @since 1.6 */ public final void lazySet(int i, int newValue) { unsafe.putOrderedInt(array, checkedByteOffset(i), newValue); }
/** * Eventually sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value * @since 1.6 */ public final void lazySet(int i, int newValue) { unsafe.putOrderedInt(array, checkedByteOffset(i), newValue); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
/** * Gets the current value at position {@code i}. * * @param i the index * @return the current value */ public final int get(int i) { return getRaw(checkedByteOffset(i)); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
/** * Eventually sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value * @since 1.6 */ public final void lazySet(int i, int newValue) { unsafe.putOrderedInt(array, checkedByteOffset(i), newValue); }