List of usage examples for com.google.common.base Preconditions checkPositionIndexes
public static void checkPositionIndexes(int start, int end, int size)
From source file:org.apache.kudu.util.Slice.java
/** * Sets the specified 16-bit short integer at the specified absolute * {@code index} in this buffer. The 16 high-order bits of the specified * value are ignored.//from w w w. j a v a2 s.co m * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 2} is greater than {@code this.capacity} */ public void setShort(int index, int value) { Preconditions.checkPositionIndexes(index, index + Shorts.BYTES, this.length); index += offset; data[index] = (byte) (value); data[index + 1] = (byte) (value >>> 8); }
From source file:org.iq80.leveldb.util.Slice.java
/** * Sets the specified 32-bit integer at the specified absolute * {@code index} in this buffer./*from w w w. j a v a2 s .c om*/ * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 4} is greater than {@code this.capacity} */ public void setInt(int index, int value) { Preconditions.checkPositionIndexes(index, index + SIZE_OF_INT, this.length); index += offset; data[index] = (byte) (value); data[index + 1] = (byte) (value >>> 8); data[index + 2] = (byte) (value >>> 16); data[index + 3] = (byte) (value >>> 24); }
From source file:org.apache.kudu.util.Slice.java
/** * Sets the specified 32-bit integer at the specified absolute * {@code index} in this buffer./*from ww w . ja va2 s . co m*/ * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 4} is greater than {@code this.capacity} */ public void setInt(int index, int value) { Preconditions.checkPositionIndexes(index, index + Ints.BYTES, this.length); index += offset; data[index] = (byte) (value); data[index + 1] = (byte) (value >>> 8); data[index + 2] = (byte) (value >>> 16); data[index + 3] = (byte) (value >>> 24); }
From source file:org.iq80.leveldb.util.Slice.java
/** * Sets the specified 64-bit long integer at the specified absolute * {@code index} in this buffer./* w ww . j ava2s . c o m*/ * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 8} is greater than {@code this.capacity} */ public void setLong(int index, long value) { Preconditions.checkPositionIndexes(index, index + SIZE_OF_LONG, this.length); index += offset; data[index] = (byte) (value); data[index + 1] = (byte) (value >>> 8); data[index + 2] = (byte) (value >>> 16); data[index + 3] = (byte) (value >>> 24); data[index + 4] = (byte) (value >>> 32); data[index + 5] = (byte) (value >>> 40); data[index + 6] = (byte) (value >>> 48); data[index + 7] = (byte) (value >>> 56); }
From source file:org.apache.kudu.util.Slice.java
/** * Sets the specified 64-bit long integer at the specified absolute * {@code index} in this buffer.//from ww w. j a v a 2s . co m * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 8} is greater than {@code this.capacity} */ public void setLong(int index, long value) { Preconditions.checkPositionIndexes(index, index + Longs.BYTES, this.length); index += offset; data[index] = (byte) (value); data[index + 1] = (byte) (value >>> 8); data[index + 2] = (byte) (value >>> 16); data[index + 3] = (byte) (value >>> 24); data[index + 4] = (byte) (value >>> 32); data[index + 5] = (byte) (value >>> 40); data[index + 6] = (byte) (value >>> 48); data[index + 7] = (byte) (value >>> 56); }
From source file:net.automatalib.commons.util.array.RichArray.java
public void sort(int startInclusive, int endExclusive, Comparator<? super T> cmp) { Preconditions.checkPositionIndexes(startInclusive, endExclusive, length); Arrays.sort(contents, start + startInclusive, start + endExclusive, cmp); }
From source file:net.automatalib.commons.util.array.RichArray.java
public void sort(int startInclusive, int endExclusive) { Preconditions.checkPositionIndexes(startInclusive, endExclusive, length); Arrays.sort(contents, start + startInclusive, start + endExclusive); }
From source file:org.iq80.leveldb.util.Slice.java
/** * Sets the specified byte at the specified absolute {@code index} in this * buffer. The 24 high-order bits of the specified value are ignored. * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 1} is greater than {@code this.capacity} *//*from w w w. j a v a2 s. c om*/ public void setByte(int index, int value) { Preconditions.checkPositionIndexes(index, index + SIZE_OF_BYTE, this.length); index += offset; data[index] = (byte) value; }
From source file:org.apache.kudu.util.Slice.java
/** * Sets the specified byte at the specified absolute {@code index} in this * buffer. The 24 high-order bits of the specified value are ignored. * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 1} is greater than {@code this.capacity} *//*w w w . j av a2s. c om*/ public void setByte(int index, int value) { Preconditions.checkPositionIndexes(index, index + 1, this.length); index += offset; data[index] = (byte) value; }
From source file:net.automatalib.commons.util.array.RichArray.java
public RichArray<T> slice(int fromIndex, int toIndex) { Preconditions.checkPositionIndexes(fromIndex, toIndex, length); return new RichArray<>(contents, start + fromIndex, start + toIndex); }