/** * 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)); }
/** * Returns the String representation of the current values of array. * @return the String representation of the current values of array */ public String toString() { int iMax = array.length - 1; if (iMax == -1) return "[]"; StringBuilder b = new StringBuilder(); b.append('['); for (int i = 0; ; i++) { b.append(getRaw(byteOffset(i))); if (i == iMax) return b.append(']').toString(); b.append(',').append(' '); } }
/** * 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; } }
/** * 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)); }
/** * 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)); }
/** * 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)); }
/** * 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)); }
/** * 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)); }
/** * 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)); }
/** * 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 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 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 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; } }
/** * 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; } }
/** * 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; } }