Java Code Examples for org.apache.commons.math.MathRuntimeException#createArrayIndexOutOfBoundsException()
The following examples show how to use
org.apache.commons.math.MathRuntimeException#createArrayIndexOutOfBoundsException() .
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 | 5 votes |
/** * Substitutes <code>value</code> for the most recently added value. * Returns the value that has been replaced. If the array is empty (i.e. * if {@link #numElements} is zero), a MathRuntimeException is thrown. * * @param value new value to substitute for the most recently added value * @return value that has been replaced in the array * @since 2.0 */ public synchronized double substituteMostRecentElement(double value) { if (numElements < 1) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY); } double discarded = internalArray[startIndex + (numElements - 1)]; internalArray[startIndex + (numElements - 1)] = value; return discarded; }
Example 2
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot set an element at a negative index {0}", index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 3
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot set an element at a negative index {0}", index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 4
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot set an element at a negative index {0}", index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 5
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Substitutes <code>value</code> for the most recently added value. * Returns the value that has been replaced. If the array is empty (i.e. * if {@link #numElements} is zero), a MathRuntimeException is thrown. * * @param value new value to substitute for the most recently added value * @return value that has been replaced in the array * @since 2.0 */ public synchronized double substituteMostRecentElement(double value) { if (numElements < 1) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot substitute an element from an empty array"); } double discarded = internalArray[startIndex + (numElements - 1)]; internalArray[startIndex + (numElements - 1)] = value; return discarded; }
Example 6
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Substitutes <code>value</code> for the most recently added value. * Returns the value that has been replaced. If the array is empty (i.e. * if {@link #numElements} is zero), a MathRuntimeException is thrown. * * @param value new value to substitute for the most recently added value * @return value that has been replaced in the array * @since 2.0 */ public synchronized double substituteMostRecentElement(double value) { if (numElements < 1) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY); } double discarded = internalArray[startIndex + (numElements - 1)]; internalArray[startIndex + (numElements - 1)] = value; return discarded; }
Example 7
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the element at the specified index * * @param index index to fetch a value from * @return value stored at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero or is greater than <code>getNumElements() - 1</code>. */ public synchronized double getElement(int index) { if (index >= numElements) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "the index specified: {0} is larger than the current maximal index {1}", index, numElements - 1); } else if (index >= 0) { return internalArray[startIndex + index]; } else { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "elements cannot be retrieved from a negative array index {0}", index); } }
Example 8
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Substitutes <code>value</code> for the most recently added value. * Returns the value that has been replaced. If the array is empty (i.e. * if {@link #numElements} is zero), a MathRuntimeException is thrown. * * @param value new value to substitute for the most recently added value * @return value that has been replaced in the array * @since 2.0 */ public synchronized double substituteMostRecentElement(double value) { if (numElements < 1) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot substitute an element from an empty array"); } double discarded = internalArray[startIndex + (numElements - 1)]; internalArray[startIndex + (numElements - 1)] = value; return discarded; }
Example 9
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the element at the specified index * * @param index index to fetch a value from * @return value stored at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero or is greater than <code>getNumElements() - 1</code>. */ public synchronized double getElement(int index) { if (index >= numElements) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "the index specified: {0} is larger than the current maximal index {1}", index, numElements - 1); } else if (index >= 0) { return internalArray[startIndex + index]; } else { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "elements cannot be retrieved from a negative array index {0}", index); } }
Example 10
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the element at the specified index * * @param index index to fetch a value from * @return value stored at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero or is greater than <code>getNumElements() - 1</code>. */ public synchronized double getElement(int index) { if (index >= numElements) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "the index specified: {0} is larger than the current maximal index {1}", index, numElements - 1); } else if (index >= 0) { return internalArray[startIndex + index]; } else { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "elements cannot be retrieved from a negative array index {0}", index); } }
Example 11
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot set an element at a negative index {0}", index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 12
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( LocalizedFormats.CANNOT_SET_AT_NEGATIVE_INDEX, index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 13
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot set an element at a negative index {0}", index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 14
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Substitutes <code>value</code> for the most recently added value. * Returns the value that has been replaced. If the array is empty (i.e. * if {@link #numElements} is zero), a MathRuntimeException is thrown. * * @param value new value to substitute for the most recently added value * @return value that has been replaced in the array * @since 2.0 */ public synchronized double substituteMostRecentElement(double value) { if (numElements < 1) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot substitute an element from an empty array"); } double discarded = internalArray[startIndex + (numElements - 1)]; internalArray[startIndex + (numElements - 1)] = value; return discarded; }
Example 15
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( LocalizedFormats.CANNOT_SET_AT_NEGATIVE_INDEX, index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 16
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot set an element at a negative index {0}", index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 17
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Substitutes <code>value</code> for the most recently added value. * Returns the value that has been replaced. If the array is empty (i.e. * if {@link #numElements} is zero), a MathRuntimeException is thrown. * * @param value new value to substitute for the most recently added value * @return value that has been replaced in the array * @since 2.0 */ public synchronized double substituteMostRecentElement(double value) { if (numElements < 1) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot substitute an element from an empty array"); } double discarded = internalArray[startIndex + (numElements - 1)]; internalArray[startIndex + (numElements - 1)] = value; return discarded; }
Example 18
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the element at the specified index. If the specified index is greater than * <code>getNumElements() - 1</code>, the <code>numElements</code> property * is increased to <code>index +1</code> and additional storage is allocated * (if necessary) for the new element and all (uninitialized) elements * between the new element and the previous end of the array). * * @param index index to store a value in * @param value value to store at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero. */ public synchronized void setElement(int index, double value) { if (index < 0) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot set an element at a negative index {0}", index); } if (index + 1 > numElements) { numElements = index + 1; } if ((startIndex + index) >= internalArray.length) { expandTo(startIndex + (index + 1)); } internalArray[startIndex + index] = value; }
Example 19
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the element at the specified index * * @param index index to fetch a value from * @return value stored at the specified index * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than * zero or is greater than <code>getNumElements() - 1</code>. */ public synchronized double getElement(int index) { if (index >= numElements) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( LocalizedFormats.INDEX_LARGER_THAN_MAX, index, numElements - 1); } else if (index >= 0) { return internalArray[startIndex + index]; } else { throw MathRuntimeException.createArrayIndexOutOfBoundsException( LocalizedFormats.CANNOT_RETRIEVE_AT_NEGATIVE_INDEX, index); } }
Example 20
Source File: ResizableDoubleArray.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Substitutes <code>value</code> for the most recently added value. * Returns the value that has been replaced. If the array is empty (i.e. * if {@link #numElements} is zero), a MathRuntimeException is thrown. * * @param value new value to substitute for the most recently added value * @return value that has been replaced in the array * @since 2.0 */ public synchronized double substituteMostRecentElement(double value) { if (numElements < 1) { throw MathRuntimeException.createArrayIndexOutOfBoundsException( "cannot substitute an element from an empty array"); } double discarded = internalArray[startIndex + (numElements - 1)]; internalArray[startIndex + (numElements - 1)] = value; return discarded; }