Package ij.util

Class FloatArray

java.lang.Object
ij.util.FloatArray

public class FloatArray
extends Object
This class implements an expandable float array similar to an ArrayList or Vector but more efficient. Calls to this class are not synchronized.
Author:
Michael Schmid
  • Constructor Summary

    Constructors 
    Constructor Description
    FloatArray()
    Creates a new expandable array with an initial capacity of 100.
    FloatArray​(int initialCapacity)
    Creates a new expandable array with specified initial capacity.
  • Method Summary

    Modifier and Type Method Description
    int add​(float value)
    Appends the specified value to the end of this FloatArray.
    int add​(float[] a, int n)
    Appends the first n values from the specified array to this FloatArray.
    void clear()
    Removes all elements form this FloatArray.
    float get​(int index)
    Returns the element at the specified position in this FloatArray.
    float getLast()
    Returns the last element of this FloatArray.
    void removeLast​(int n)
    Deletes the last n element from this FloatArray.
    float set​(int index, float value)
    Replaces the element at the specified position with the value given.
    int size()
    Returns the number of elements in the array.
    float[] toArray()
    Returns a float array containing all elements of this FloatArray.
    void trimToSize()
    Trims the capacity of this FloatArray instance to be its current size, minimizing the storage of the FloatArray instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FloatArray

      public FloatArray()
      Creates a new expandable array with an initial capacity of 100.
    • FloatArray

      public FloatArray​(int initialCapacity)
      Creates a new expandable array with specified initial capacity.
      Throws:
      IllegalArgumentException - if the specified initial capacity is less than zero
  • Method Details

    • size

      public int size()
      Returns the number of elements in the array.
    • clear

      public void clear()
      Removes all elements form this FloatArray.
    • toArray

      public float[] toArray()
      Returns a float array containing all elements of this FloatArray.
    • get

      public float get​(int index)
      Returns the element at the specified position in this FloatArray.
      Throws:
      IndexOutOfBoundsException - - if index is out of range (index < 0 || index >= size()).
    • getLast

      public float getLast()
      Returns the last element of this FloatArray.
      Throws:
      IndexOutOfBoundsException - - if this FloatArray is empty
    • set

      public float set​(int index, float value)
      Replaces the element at the specified position with the value given.
      Returns:
      the value previously at the specified position.
      Throws:
      IndexOutOfBoundsException - - if index is out of range (index < 0 || index >= size()).
    • add

      public int add​(float value)
      Appends the specified value to the end of this FloatArray. Returns the number of elements after adding.
    • add

      public int add​(float[] a, int n)
      Appends the first n values from the specified array to this FloatArray. Returns the number of elements after adding.
    • removeLast

      public void removeLast​(int n)
      Deletes the last n element from this FloatArray. n may be larger than the number of elements; in that case, all elements are removed.
    • trimToSize

      public void trimToSize()
      Trims the capacity of this FloatArray instance to be its current size, minimizing the storage of the FloatArray instance.