Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#INDEX_NOT_POSITIVE

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#INDEX_NOT_POSITIVE . 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: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws MathIllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i)
    throws MathIllegalArgumentException {
    // If index is negative thrown an error.
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements.
    final int newSize = startIndex + i;
    if (newSize > internalArray.length) {
        expandTo(newSize);
    }

    // Set the new number of elements to new value.
    numElements = i;
}
 
Example 2
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws MathIllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i) throws MathIllegalArgumentException {

    // If index is negative thrown an error
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements
    if ((startIndex + i) > internalArray.length) {
        expandTo(startIndex + i);
    }

    // Set the new number of elements to new value
    numElements = i;
}
 
Example 3
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws IllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i) {

    // If index is negative thrown an error
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements
    if ((startIndex + i) > internalArray.length) {
        expandTo(startIndex + i);
    }

    // Set the new number of elements to new value
    numElements = i;
}
 
Example 4
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws MathIllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i)
    throws MathIllegalArgumentException {
    // If index is negative thrown an error.
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements.
    final int newSize = startIndex + i;
    if (newSize > internalArray.length) {
        expandTo(newSize);
    }

    // Set the new number of elements to new value.
    numElements = i;
}
 
Example 5
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws IllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i) {

    // If index is negative thrown an error
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements
    if ((startIndex + i) > internalArray.length) {
        expandTo(startIndex + i);
    }

    // Set the new number of elements to new value
    numElements = i;
}
 
Example 6
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws MathIllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i)
    throws MathIllegalArgumentException {
    // If index is negative thrown an error.
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements.
    final int newSize = startIndex + i;
    if (newSize > internalArray.length) {
        expandTo(newSize);
    }

    // Set the new number of elements to new value.
    numElements = i;
}
 
Example 7
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws MathIllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i)
    throws MathIllegalArgumentException {
    // If index is negative thrown an error.
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements.
    final int newSize = startIndex + i;
    if (newSize > internalArray.length) {
        expandTo(newSize);
    }

    // Set the new number of elements to new value.
    numElements = i;
}
 
Example 8
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function allows you to control the number of elements contained
 * in this array, and can be used to "throw out" the last n values in an
 * array. This function will also expand the internal array as needed.
 *
 * @param i a new number of elements
 * @throws MathIllegalArgumentException if <code>i</code> is negative.
 */
public synchronized void setNumElements(int i)
    throws MathIllegalArgumentException {
    // If index is negative thrown an error.
    if (i < 0) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INDEX_NOT_POSITIVE,
                i);
    }

    // Test the new num elements, check to see if the array needs to be
    // expanded to accommodate this new number of elements.
    final int newSize = startIndex + i;
    if (newSize > internalArray.length) {
        expandTo(newSize);
    }

    // Set the new number of elements to new value.
    numElements = i;
}