Package rma.util

Class IntArray

java.lang.Object
rma.util.IntArray
All Implemented Interfaces:
AsciiSerializable, FieldAccessor, Serializable, Cloneable

public class IntArray extends Object implements Cloneable, Serializable, AsciiSerializable
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    The amount by which the capacity of the array is automatically incremented when its size becomes greater than its capacity.
    protected int
    The number of valid components in the array.
    protected int[]
    The array buffer into which the components of the array are stored.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty array.
    IntArray(int initialCapacity)
    Constructs an empty array with the specified initial capacity.
    IntArray(int[] array)
    Constructs a new IntArray with the capacity set to the argument array length then copys the argument array data into the element data array.
    IntArray(int initialCapacity, int capacityIncrement)
    Constructs an empty array with the specified initial capacity and capacity increment.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int obj)
    Adds the specified component to the end of this array, increasing its size by one.
    boolean
    addAll(int[] array)
    Appends the ints in the argument array to this int array.
    boolean
    Appends the ints in the argument array to this int array.
    final void
    addElement(int obj)
    Adds the specified component to the end of this array, increasing its size by one.
    final int
    Returns the current capacity of this array.
    void
    Removes all components from this array and sets its size to zero.
    Returns a clone of this array.
    final boolean
    contains(int elem)
    Tests if the specified int is a component in this array.
    final void
    copyInto(int[] anArray)
    Copies the components of this array into the specified array.
    final void
    copyInto(Integer[] anArray)
    Copies the components of this array into the specified array.
    final int
    elementAt(int index)
    Returns the component at the specified index.
    long
    Returns the total value of all the elements
    final void
    ensureCapacity(int minCapacity)
    Increases the capacity of this array, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
    final int
    Returns the first component of this array.
    int
    get(int index)
    Returns the component at the specified index.
    Gets the FieldObject attribute of the IntVector object
    final int
    indexOf(int elem)
    Searches for the first occurence of the given argument, testing for equality using the equals method.
    final int
    indexOf(int elem, int index)
    Searches for the first occurence of the given argument, beginning the search at index , and testing for equality using the equals method.
    final void
    insertElementAt(int obj, int index)
    Inserts the specified int as a component in this array at the specified index .
    final boolean
    Tests if this array has no components.
    final int
    Returns the last component of the array.
    final int
    lastIndexOf(int elem)
    Returns the index of the last occurrence of the specified int in this array.
    final int
    lastIndexOf(int elem, int index)
    Searches backwards for the specified int, starting from the specified index, and returns an index to it.
    boolean
    remove(int obj)
    Removes the first occurrence of the argument from this array.
    int
    removeAll(int[] objs)
    Removes the first occurrence of the argument from this array.
    final void
    Removes all components from this array and sets its size to zero.
    final boolean
    removeElement(int obj)
    Removes the first occurrence of the argument from this array.
    final void
    removeElementAt(int index)
    Deletes the component at the specified index.
    final int
    remove and return the last element of the array
    final void
    setElementAt(int obj, int index)
    Sets the component at the specified index of this array to be the specified int.
    boolean
    Sets the FieldObject attribute of the IntVector object
    final void
    setSize(int newSize)
    Sets the size of this array.
    final int
    Returns the number of components in this array.
    int[]
    Returns the int data in a new array.
    final String
    Returns a string representation of this array.
    final void
    Trims the capacity of this array to be the arrays's current size.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • _elementData

      protected int[] _elementData
      The array buffer into which the components of the array are stored. The capacity of the array is the length of this array buffer.
    • _elementCount

      protected int _elementCount
      The number of valid components in the array.
    • _capacityIncrement

      protected int _capacityIncrement
      The amount by which the capacity of the array is automatically incremented when its size becomes greater than its capacity. If the capacity increment is 0 , the capacity of the array is doubled each time it needs to grow.
  • Constructor Details

    • IntArray

      public IntArray(int initialCapacity, int capacityIncrement)
      Constructs an empty array with the specified initial capacity and capacity increment.
      Parameters:
      initialCapacity - the initial capacity of the array.
      capacityIncrement - the amount by which the capacity is increased when the array overflows.
    • IntArray

      public IntArray(int initialCapacity)
      Constructs an empty array with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the array.
    • IntArray

      public IntArray()
      Constructs an empty array.
    • IntArray

      public IntArray(int[] array)
      Constructs a new IntArray with the capacity set to the argument array length then copys the argument array data into the element data array.
      Parameters:
      array -
  • Method Details

    • addAll

      public boolean addAll(int[] array)
      Appends the ints in the argument array to this int array. Returns a boolean if the number of ints added is > 0.
    • addAll

      public boolean addAll(IntVector iv)
      Appends the ints in the argument array to this int array. Returns a boolean if the number of ints added is > 0.
    • toArray

      public int[] toArray()
      Returns the int data in a new array.
      Returns:
    • copyInto

      public final void copyInto(int[] anArray)
      Copies the components of this array into the specified array. The array must be big enough to hold all the ints in this array.
      Parameters:
      anArray - the array into which the components get copied.
    • copyInto

      public final void copyInto(Integer[] anArray)
      Copies the components of this array into the specified array. The array must be big enough to hold all the ints in this array.
      Parameters:
      anArray - the Integer array into which the components get copied.
    • trimToSize

      public final void trimToSize()
      Trims the capacity of this array to be the arrays's current size. An application can use this operation to minimize the storage of a array.
    • ensureCapacity

      public final void ensureCapacity(int minCapacity)
      Increases the capacity of this array, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
      Parameters:
      minCapacity - the desired minimum capacity.
    • setSize

      public final void setSize(int newSize)
      Sets the size of this array. If the new size is greater than the current size, new RMAConst.UNDEF_INT items are added to the end of the array. If the new size is less than the current size, all components at index newSize and greater are discarded.
      Parameters:
      newSize - the new size of this array.
    • capacity

      public final int capacity()
      Returns the current capacity of this array.
      Returns:
      the current capacity of this array.
      Since:
      JDK1.0
    • size

      public final int size()
      Returns the number of components in this array.
      Returns:
      the number of components in this array.
      Since:
      JDK1.0
    • isEmpty

      public final boolean isEmpty()
      Tests if this array has no components.
      Returns:
      true if this array has no components; false otherwise.
      Since:
      JDK1.0
    • contains

      public final boolean contains(int elem)
      Tests if the specified int is a component in this array.
      Parameters:
      elem - an int.
      Returns:
      true if the specified int is a component in this array; false otherwise.
      Since:
      JDK1.0
    • indexOf

      public final int indexOf(int elem)
      Searches for the first occurence of the given argument, testing for equality using the equals method.
      Parameters:
      elem - an int.
      Returns:
      the index of the first occurrence of the argument in this array; returns -1 if the int is not found.
      Since:
      JDK1.0
      See Also:
    • indexOf

      public final int indexOf(int elem, int index)
      Searches for the first occurence of the given argument, beginning the search at index , and testing for equality using the equals method.
      Parameters:
      elem - an int.
      index - the index to start searching from.
      Returns:
      the index of the first occurrence of the int argument in this array at position index or later in the array; returns -1 if the int is not found.
      Since:
      JDK1.0
      See Also:
    • lastIndexOf

      public final int lastIndexOf(int elem)
      Returns the index of the last occurrence of the specified int in this array.
      Parameters:
      elem - the desired component.
      Returns:
      the index of the last occurrence of the specified int in this array; returns -1 if the int is not found.
      Since:
      JDK1.0
    • lastIndexOf

      public final int lastIndexOf(int elem, int index)
      Searches backwards for the specified int, starting from the specified index, and returns an index to it.
      Parameters:
      elem - the desired component.
      index - the index to start searching from.
      Returns:
      the index of the last occurrence of the specified int in this array at position less than index in the array; -1 if the int is not found.
      Since:
      JDK1.0
    • get

      public int get(int index)
      Returns the component at the specified index. wrapper for elementAt(int);
      Parameters:
      index - Description
      Returns:
      Description
    • elementAt

      public final int elementAt(int index)
      Returns the component at the specified index.
      Parameters:
      index - an index into this array.
      Returns:
      the component at the specified index.
      Since:
      JDK1.0
    • firstElement

      public final int firstElement()
      Returns the first component of this array.
      Returns:
      the first component of this array.
      Since:
      JDK1.0
    • lastElement

      public final int lastElement()
      Returns the last component of the array.
      Returns:
      the last component of the array, i.e., the component at index size() - 1 .
      Since:
      JDK1.0
    • removeLastElement

      public final int removeLastElement()
      remove and return the last element of the array
      Returns:
    • setElementAt

      public final void setElementAt(int obj, int index)
      Sets the component at the specified index of this array to be the specified int. The previous component at that position is discarded.

      The index must be a value greater than or equal to 0 and less than the current size of the array.

      Parameters:
      obj - what the component is to be set to.
      index - the specified index.
      Since:
      JDK1.0
    • removeElementAt

      public final void removeElementAt(int index)
      Deletes the component at the specified index. Each component in this array with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously.

      The index must be a value greater than or equal to 0 and less than the current size of the array.

      Parameters:
      index - the index of the int to remove.
      Since:
      JDK1.0
    • insertElementAt

      public final void insertElementAt(int obj, int index)
      Inserts the specified int as a component in this array at the specified index . Each component in this array with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.

      The index must be a value greater than or equal to 0 and less than or equal to the current size of the array.

      Parameters:
      obj - the component to insert.
      index - where to insert the new component.
      Since:
      JDK1.0
    • add

      public void add(int obj)
      Adds the specified component to the end of this array, increasing its size by one. The capacity of this array is increased if its size becomes greater than its capacity. wrapper for addElement(int);
      Parameters:
      obj - Description
    • addElement

      public final void addElement(int obj)
      Adds the specified component to the end of this array, increasing its size by one. The capacity of this array is increased if its size becomes greater than its capacity.
      Parameters:
      obj - the component to be added.
      Since:
      JDK1.0
    • remove

      public boolean remove(int obj)
      Removes the first occurrence of the argument from this array. If the int is found in this array, each component in the array with an index greater or equal to the int's index is shifted downward to have an index one smaller than the value it had previously. wrapper for removeElement(int)
      Parameters:
      obj - Description
      Returns:
      Description
    • removeAll

      public int removeAll(int[] objs)
      Removes the first occurrence of the argument from this array. If the int is found in this array, each component in the array with an index greater or equal to the int's index is shifted downward to have an index one smaller than the value it had previously.
      Parameters:
      objs - Description
      Returns:
      the number of items removed
    • removeElement

      public final boolean removeElement(int obj)
      Removes the first occurrence of the argument from this array. If the int is found in this array, each component in the array with an index greater or equal to the int's index is shifted downward to have an index one smaller than the value it had previously.
      Parameters:
      obj - the component to be removed.
      Returns:
      true if the argument was a component of this array; false otherwise.
    • clear

      public void clear()
      Removes all components from this array and sets its size to zero. wrapper for removeAllElements();
    • removeAllElements

      public final void removeAllElements()
      Removes all components from this array and sets its size to zero.
    • clone

      public Object clone()
      Returns a clone of this array.
      Overrides:
      clone in class Object
      Returns:
      a clone of this array.
      Since:
      JDK1.0
    • elementTotal

      public long elementTotal()
      Returns the total value of all the elements
    • toString

      public final String toString()
      Returns a string representation of this array.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this array.
      Since:
      JDK1.0
    • getFieldObject

      public Object getFieldObject(Field fld)
      Gets the FieldObject attribute of the IntVector object
      Specified by:
      getFieldObject in interface FieldAccessor
      Parameters:
      fld - Description
      Returns:
      The FieldObject value
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Sets the FieldObject attribute of the IntVector object
      Specified by:
      setFieldObject in interface FieldAccessor
      Parameters:
      fld - The new FieldObject value
      fobj - The new FieldObject value
      Returns:
      Description