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

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#INITIAL_CAPACITY_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
/**
 * Creates an instance with the specified properties.
 * <br/>
 * Throws MathIllegalArgumentException if the following conditions are
 * not met:
 * <ul>
 *  <li>{@code initialCapacity > 0}</li>
 *  <li>{@code expansionFactor > 1}</li>
 *  <li>{@code contractionCriterion >= expansionFactor}</li>
 * </ul>
 *
 * @param initialCapacity Initial size of the internal storage array.
 * @param expansionFactor The array will be expanded based on this
 * parameter.
 * @param contractionCriterion Contraction criteria.
 * @param expansionMode Expansion mode.
 * @param data Initial contents of the array.
 * @throws MathIllegalArgumentException if the parameters are not valid.
 */
public ResizableDoubleArray(int initialCapacity,
                            double expansionFactor,
                            double contractionCriterion,
                            ExpansionMode expansionMode,
                            double ... data)
    throws MathIllegalArgumentException {
    if (initialCapacity <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                                               initialCapacity);
    }
    checkContractExpand(contractionCriterion, expansionFactor);

    this.expansionFactor = expansionFactor;
    this.contractionCriterion = contractionCriterion;
    this.expansionMode = expansionMode;
    internalArray = new double[initialCapacity];
    numElements = 0;
    startIndex = 0;

    if (data != null && data.length > 1) {
        addElements(data);
    }
}
 
Example 2
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an instance with the specified properties.
 * <br/>
 * Throws MathIllegalArgumentException if the following conditions are
 * not met:
 * <ul>
 *  <li>{@code initialCapacity > 0}</li>
 *  <li>{@code expansionFactor > 1}</li>
 *  <li>{@code contractionCriterion >= expansionFactor}</li>
 * </ul>
 *
 * @param initialCapacity Initial size of the internal storage array.
 * @param expansionFactor The array will be expanded based on this
 * parameter.
 * @param contractionCriterion Contraction criteria.
 * @param expansionMode Expansion mode.
 * @param data Initial contents of the array.
 * @throws MathIllegalArgumentException if the parameters are not valid.
 */
public ResizableDoubleArray(int initialCapacity,
                            double expansionFactor,
                            double contractionCriterion,
                            ExpansionMode expansionMode,
                            double ... data)
    throws MathIllegalArgumentException {
    if (initialCapacity <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                                               initialCapacity);
    }
    checkContractExpand(contractionCriterion, expansionFactor);

    this.expansionFactor = expansionFactor;
    this.contractionCriterion = contractionCriterion;
    this.expansionMode = expansionMode;
    internalArray = new double[initialCapacity];
    numElements = 0;
    startIndex = 0;

    if (data != null) {
        addElements(data);
    }
}
 
Example 3
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an instance with the specified properties.
 * <br/>
 * Throws MathIllegalArgumentException if the following conditions are
 * not met:
 * <ul>
 *  <li>{@code initialCapacity > 0}</li>
 *  <li>{@code expansionFactor > 1}</li>
 *  <li>{@code contractionCriterion >= expansionFactor}</li>
 * </ul>
 *
 * @param initialCapacity Initial size of the internal storage array.
 * @param expansionFactor The array will be expanded based on this
 * parameter.
 * @param contractionCriterion Contraction criteria.
 * @param expansionMode Expansion mode.
 * @param data Initial contents of the array.
 * @throws MathIllegalArgumentException if the parameters are not valid.
 */
public ResizableDoubleArray(int initialCapacity,
                            double expansionFactor,
                            double contractionCriterion,
                            ExpansionMode expansionMode,
                            double ... data)
    throws MathIllegalArgumentException {
    if (initialCapacity <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                                               initialCapacity);
    }
    checkContractExpand(contractionCriterion, expansionFactor);

    this.expansionFactor = expansionFactor;
    this.contractionCriterion = contractionCriterion;
    this.expansionMode = expansionMode;
    internalArray = new double[initialCapacity];
    numElements = 0;
    startIndex = 0;

    if (data != null) {
        addElements(data);
    }
}
 
Example 4
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an instance with the specified properties.
 * <br/>
 * Throws MathIllegalArgumentException if the following conditions are
 * not met:
 * <ul>
 *  <li>{@code initialCapacity > 0}</li>
 *  <li>{@code expansionFactor > 1}</li>
 *  <li>{@code contractionCriterion >= expansionFactor}</li>
 * </ul>
 *
 * @param initialCapacity Initial size of the internal storage array.
 * @param expansionFactor The array will be expanded based on this
 * parameter.
 * @param contractionCriterion Contraction criteria.
 * @param expansionMode Expansion mode.
 * @param data Initial contents of the array.
 * @throws MathIllegalArgumentException if the parameters are not valid.
 */
public ResizableDoubleArray(int initialCapacity,
                            double expansionFactor,
                            double contractionCriterion,
                            ExpansionMode expansionMode,
                            double ... data)
    throws MathIllegalArgumentException {
    if (initialCapacity <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                                               initialCapacity);
    }
    checkContractExpand(contractionCriterion, expansionFactor);

    this.expansionFactor = expansionFactor;
    this.contractionCriterion = contractionCriterion;
    this.expansionMode = expansionMode;
    internalArray = new double[initialCapacity];
    numElements = 0;
    startIndex = 0;

    if (data != null) {
        addElements(data);
    }
}
 
Example 5
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an instance with the specified properties.
 * <br/>
 * Throws MathIllegalArgumentException if the following conditions are
 * not met:
 * <ul>
 *  <li>{@code initialCapacity > 0}</li>
 *  <li>{@code expansionFactor > 1}</li>
 *  <li>{@code contractionCriterion >= expansionFactor}</li>
 * </ul>
 *
 * @param initialCapacity Initial size of the internal storage array.
 * @param expansionFactor The array will be expanded based on this
 * parameter.
 * @param contractionCriterion Contraction criteria.
 * @param expansionMode Expansion mode.
 * @param data Initial contents of the array.
 * @throws MathIllegalArgumentException if the parameters are not valid.
 */
public ResizableDoubleArray(int initialCapacity,
                            double expansionFactor,
                            double contractionCriterion,
                            ExpansionMode expansionMode,
                            double ... data)
    throws MathIllegalArgumentException {
    if (initialCapacity <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                                               initialCapacity);
    }
    checkContractExpand(contractionCriterion, expansionFactor);

    this.expansionFactor = expansionFactor;
    this.contractionCriterion = contractionCriterion;
    this.expansionMode = expansionMode;
    internalArray = new double[initialCapacity];
    numElements = 0;
    startIndex = 0;

    if (data != null && data.length > 1) {
        addElements(data);
    }
}
 
Example 6
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the initial capacity.  Should only be invoked by constructors.
 *
 * @param initialCapacity of the array
 * @throws MathIllegalArgumentException if <code>initialCapacity</code> is not
 *         positive.
 */
protected void setInitialCapacity(int initialCapacity) throws MathIllegalArgumentException {
    if (initialCapacity > 0) {
        synchronized(this) {
            this.initialCapacity = initialCapacity;
        }
    } else {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                initialCapacity);
    }
}
 
Example 7
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the initial capacity.  Should only be invoked by constructors.
 *
 * @param initialCapacity of the array
 * @throws IllegalArgumentException if <code>initialCapacity</code> is not
 *         positive.
 */
protected void setInitialCapacity(int initialCapacity) {
    if (initialCapacity > 0) {
        synchronized(this) {
            this.initialCapacity = initialCapacity;
        }
    } else {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                initialCapacity);
    }
}
 
Example 8
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the initial capacity.  Should only be invoked by constructors.
 *
 * @param initialCapacity of the array
 * @throws IllegalArgumentException if <code>initialCapacity</code> is not
 *         positive.
 */
protected void setInitialCapacity(int initialCapacity) {
    if (initialCapacity > 0) {
        synchronized(this) {
            this.initialCapacity = initialCapacity;
        }
    } else {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
                initialCapacity);
    }
}