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

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY . 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 vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value New value to substitute for the most recently added value
 * @return the value that has been replaced in the array.
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value)
    throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    final int substIndex = startIndex + (numElements - 1);
    final double discarded = internalArray[substIndex];

    internalArray[substIndex] = value;

    return discarded;
}
 
Example 2
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value new value to substitute for the most recently added value
 * @return value that has been replaced in the array
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value) throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    double discarded = internalArray[startIndex + (numElements - 1)];

    internalArray[startIndex + (numElements - 1)] = value;

    return discarded;
}
 
Example 3
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value new value to substitute for the most recently added value
 * @return value that has been replaced in the array
 * @throws IllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value) {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    double discarded = internalArray[startIndex + (numElements - 1)];

    internalArray[startIndex + (numElements - 1)] = value;

    return discarded;
}
 
Example 4
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value New value to substitute for the most recently added value
 * @return the value that has been replaced in the array.
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value)
    throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    final int substIndex = startIndex + (numElements - 1);
    final double discarded = internalArray[substIndex];

    internalArray[substIndex] = value;

    return discarded;
}
 
Example 5
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value new value to substitute for the most recently added value
 * @return value that has been replaced in the array
 * @throws IllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value) {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_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 vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value New value to substitute for the most recently added value
 * @return the value that has been replaced in the array.
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value)
    throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    final int substIndex = startIndex + (numElements - 1);
    final double discarded = internalArray[substIndex];

    internalArray[substIndex] = value;

    return discarded;
}
 
Example 7
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value New value to substitute for the most recently added value
 * @return the value that has been replaced in the array.
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value)
    throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    final int substIndex = startIndex + (numElements - 1);
    final double discarded = internalArray[substIndex];

    internalArray[substIndex] = value;

    return discarded;
}
 
Example 8
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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), an IllegalStateException is thrown.
 *
 * @param value New value to substitute for the most recently added value
 * @return the value that has been replaced in the array.
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value)
    throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    final int substIndex = startIndex + (numElements - 1);
    final double discarded = internalArray[substIndex];

    internalArray[substIndex] = value;

    return discarded;
}