Java Code Examples for java.util.Objects#checkIndex()

The following examples show how to use java.util.Objects#checkIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldsIndexReader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
long getStartPointer(int docID) {
  Objects.checkIndex(docID, maxDoc);
  long blockIndex = docs.binarySearch(0, numChunks, docID);
  if (blockIndex < 0) {
    blockIndex = -2 - blockIndex;
  }
  return startPointers.get(blockIndex);
}
 
Example 2
Source File: AtomicMuiltInteger2.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
/**
 * 递增并获取该位置的值
 * 
 * @param index
 * @return
 */
public int incrementAndGet(int index) {
	Objects.checkIndex(index, count);

	unsafe().getAndAddInt(array, sumIndex, 1);
	return unsafe().getAndAddInt(array, offset(index), 1) + 1;
}
 
Example 3
Source File: BigEndianDataConverter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public long getValue(byte[] b, int offset, int size) {
	Objects.checkFromIndexSize(offset, size, b.length);
	Objects.checkIndex(size, Long.BYTES + 1);

	long val = 0;
	for (int i = 0; i < size; i++) {
		val = (val << 8) | (b[offset + i] & 0xff);
	}
	return val;
}
 
Example 4
Source File: ConcurrentArrayList.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
public void set(int index, T value) {
	Objects.checkIndex(index, size);
	final long offset = offset(ABASE, ASHIFT, index);

	for (;;) {// like cas
		final Object[] before = values;
		unsafe().putOrderedObject(before, offset, value);
		final Object[] after = values;

		if (before == after) {
			return;
		}
	}
}
 
Example 5
Source File: LittleEndianDataConverter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public long getValue(byte[] b, int offset, int size) {
	Objects.checkFromIndexSize(offset, size, b.length);
	Objects.checkIndex(size, Long.BYTES + 1);

	long val = 0;
	for (int i = size - 1; i >= 0; i--) {
		val = (val << 8) | (b[offset + i] & 0xff);
	}
	return val;
}
 
Example 6
Source File: ConcurrentArrayList.java    From turbo-rpc with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public T get(int index) {
	Objects.checkIndex(index, size);
	return (T) unsafe().getObjectVolatile(values, offset(ABASE, ASHIFT, index));
}
 
Example 7
Source File: StableList.java    From pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public E get(int index) {
  Objects.checkIndex(index, size);
  return array[index];
}
 
Example 8
Source File: CharTermAttributeImpl.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public final char charAt(int index) {
  Objects.checkIndex(index, termLength);
  return termBuffer[index];
}
 
Example 9
Source File: BitsSlice.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public boolean get(int doc) {
  Objects.checkIndex(doc, length);
  return parent.get(doc+start);
}
 
Example 10
Source File: Function.java    From Java-Coding-Problems with MIT License 4 votes vote down vote up
public int xMinusY(int y) {
    Objects.checkIndex(y, x);

    return x - y;
}
 
Example 11
Source File: AtomicMuiltInteger2.java    From turbo-rpc with Apache License 2.0 3 votes vote down vote up
/**
 * 增加并获取该位置的值
 * 
 * @param index
 * @param delta
 * @return
 */
public int addAndGet(int index, int delta) {
	Objects.checkIndex(index, count);

	unsafe().getAndAddInt(array, sumIndex, delta);
	return unsafe().getAndAddInt(array, offset(index), delta) + delta;
}
 
Example 12
Source File: DoubleRange.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Get the max value for the given dimension
 * @param dimension the dimension, always positive
 * @return the decoded max value
 */
public double getMax(int dimension) {
  Objects.checkIndex(dimension, type.pointDimensionCount()/2);
  return decodeMax(((BytesRef)fieldsData).bytes, dimension);
}
 
Example 13
Source File: FloatRange.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Get the min value for the given dimension
 * @param dimension the dimension, always positive
 * @return the decoded min value
 */
public float getMin(int dimension) {
  Objects.checkIndex(dimension, type.pointDimensionCount()/2);
  return decodeMin(((BytesRef)fieldsData).bytes, dimension);
}
 
Example 14
Source File: IntRange.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Get the max value for the given dimension
 * @param dimension the dimension, always positive
 * @return the decoded max value
 */
public int getMax(int dimension) {
  Objects.checkIndex(dimension, type.pointDimensionCount()/2);
  return decodeMax(((BytesRef)fieldsData).bytes, dimension);
}
 
Example 15
Source File: AtomicMuiltInteger.java    From turbo-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * 递增并获取该位置的值
 * 
 * @param index
 * @return
 */
public int incrementAndGet(int index) {
	Objects.checkIndex(index, count);
	return unsafe().getAndAddInt(array, offset(index), 1) + 1;
}
 
Example 16
Source File: AtomicMuiltInteger.java    From turbo-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * 增加并获取该位置的值
 * 
 * @param index
 * @param delta
 * @return
 */
public int addAndGet(int index, int delta) {
	Objects.checkIndex(index, count);
	return unsafe().getAndAddInt(array, offset(index), delta) + delta;
}
 
Example 17
Source File: AtomicMuiltInteger.java    From turbo-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * 某个位置的值
 * 
 * @param index
 * @return
 */
public int get(int index) {
	Objects.checkIndex(index, count);
	return unsafe().getIntVolatile(array, offset(index));
}
 
Example 18
Source File: AtomicMuiltInteger.java    From turbo-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * 设置某位置的值
 * 
 * @param index
 * @param value
 */
public void set(int index, int value) {
	Objects.checkIndex(index, count);
	unsafe().putOrderedInt(array, offset(index), value);
}
 
Example 19
Source File: IntRange.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Get the min value for the given dimension
 * @param dimension the dimension, always positive
 * @return the decoded min value
 */
public int getMin(int dimension) {
  Objects.checkIndex(dimension, type.pointDimensionCount()/2);
  return decodeMin(((BytesRef)fieldsData).bytes, dimension);
}
 
Example 20
Source File: FloatRange.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Get the max value for the given dimension
 * @param dimension the dimension, always positive
 * @return the decoded max value
 */
public float getMax(int dimension) {
  Objects.checkIndex(dimension, type.pointDimensionCount()/2);
  return decodeMax(((BytesRef)fieldsData).bytes, dimension);
}