本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY属性的具体用法?Java LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY怎么用?Java LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: discardExtremeElements
/**
* Discards the <code>i</code> first or last elements of the array,
* depending on the value of <code>front</code>.
* For example, if the array contains the elements 1,2,3,4, invoking
* <code>discardExtremeElements(2,false)</code> will cause the last two elements
* to be discarded, leaving 1,2 in the array.
* For example, if the array contains the elements 1,2,3,4, invoking
* <code>discardExtremeElements(2,true)</code> will cause the first two elements
* to be discarded, leaving 3,4 in the array.
* Throws illegalArgumentException
* if i exceeds numElements.
*
* @param i the number of elements to discard from the front/end of the array
* @param front true if elements are to be discarded from the front
* of the array, false if elements are to be discarded from the end
* of the array
* @throws MathIllegalArgumentException if i is greater than numElements.
* @since 2.0
*/
private synchronized void discardExtremeElements(int i,
boolean front)
throws MathIllegalArgumentException {
if (i > numElements) {
throw new MathIllegalArgumentException(
LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY,
i, numElements);
} else if (i < 0) {
throw new MathIllegalArgumentException(
LocalizedFormats.CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS,
i);
} else {
// "Subtract" this number of discarded from numElements
numElements -= i;
if (front) {
startIndex += i;
}
}
if (shouldContract()) {
contract();
}
}
示例2: discardExtremeElements
/**
* Discards the <code>i<code> first or last elements of the array,
* depending on the value of <code>front</code>.
* For example, if the array contains the elements 1,2,3,4, invoking
* <code>discardExtremeElements(2,false)</code> will cause the last two elements
* to be discarded, leaving 1,2 in the array.
* For example, if the array contains the elements 1,2,3,4, invoking
* <code>discardExtremeElements(2,true)</code> will cause the first two elements
* to be discarded, leaving 3,4 in the array.
* Throws illegalArgumentException
* if i exceeds numElements.
*
* @param i the number of elements to discard from the front/end of the array
* @param front true if elements are to be discarded from the front
* of the array, false if elements are to be discarded from the end
* of the array
* @throws IllegalArgumentException if i is greater than numElements.
* @since 2.0
*/
private synchronized void discardExtremeElements(int i,boolean front) {
if (i > numElements) {
throw new MathIllegalArgumentException(
LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY,
i, numElements);
} else if (i < 0) {
throw new MathIllegalArgumentException(
LocalizedFormats.CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS,
i);
} else {
// "Subtract" this number of discarded from numElements
numElements -= i;
if (front) {
startIndex += i;
}
}
if (shouldContract()) {
contract();
}
}