本文整理匯總了Java中com.google.common.base.Preconditions.checkPositionIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java Preconditions.checkPositionIndex方法的具體用法?Java Preconditions.checkPositionIndex怎麽用?Java Preconditions.checkPositionIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.base.Preconditions
的用法示例。
在下文中一共展示了Preconditions.checkPositionIndex方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: forArray
import com.google.common.base.Preconditions; //導入方法依賴的package包/類
/**
* Returns a list iterator containing the elements in the specified range of
* {@code array} in order, starting at the specified index.
*
* <p>The {@code Iterable} equivalent of this method is {@code
* Arrays.asList(array).subList(offset, offset + length).listIterator(index)}.
*/
static <T> UnmodifiableListIterator<T> forArray(
final T[] array, final int offset, int length, int index) {
checkArgument(length >= 0);
int end = offset + length;
// Technically we should give a slightly more descriptive error on overflow
Preconditions.checkPositionIndexes(offset, end, array.length);
Preconditions.checkPositionIndex(index, length);
if (length == 0) {
return emptyListIterator();
}
return new ArrayItr<T>(array, offset, length, index);
}
示例2: setPage
import com.google.common.base.Preconditions; //導入方法依賴的package包/類
@SuppressWarnings("null")
public boolean setPage(int page) {
Preconditions.checkPositionIndex(page, messages.size());
BakedMessage message = messages.get(page);
if (sentMessage != null) {
message.update(sentMessage);
}
this.page = page;
this.lastUpdate = System.currentTimeMillis();
return true;
}
示例3: getDimension
import com.google.common.base.Preconditions; //導入方法依賴的package包/類
public float getDimension(int index) {
Preconditions.checkPositionIndex(index, this.size());
return dimensions[index];
}
示例4: getPoint
import com.google.common.base.Preconditions; //導入方法依賴的package包/類
public TimeSeriesPoint getPoint(int index) {
Preconditions.checkPositionIndex(index, points.size());
return points.get(index);
}
示例5: getEntryAt
import com.google.common.base.Preconditions; //導入方法依賴的package包/類
/**
* Get the entry at the specified position
* @param pos Position of the entry to be obtained
* @return integer representation of AclEntry
* @throws IndexOutOfBoundsException if pos out of bound
*/
int getEntryAt(int pos) {
Preconditions.checkPositionIndex(pos, entries.length,
"Invalid position for AclEntry");
return entries[pos];
}