processing.data

## Class FloatList

- Object
- - FloatList

- All Implemented Interfaces:
    Iterable<Float>

      public class FloatList
      extends Object
      implements Iterable<Float>

  Helper class for a list of floats. Lists are designed to have some of the features of ArrayLists, but to maintain the simplicity and efficiency of working with arrays. Functions like sort() and shuffle() always act on the list itself. To get a sorted copy, use list.copy().sort().
  See Also:
    `IntList`, `StringList`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FloatList()`
    `FloatList(float[] list)`
    `FloatList(int length)`
    `FloatList(Iterable<Float> iter)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(int index, float amount)`
    `void` | `append(float value)` Add a new entry to the list.
    `void` | `append(float[] values)`
    `void` | `append(FloatList list)`
    `float[]` | `array()` Create a new array with a copy of all the values.
    `float[]` | `array(float[] array)` Copy values into the specified array.
    `void` | `clear()` Remove all entries from the list.
    `FloatList` | `copy()`
    `void` | `div(int index, float amount)`
    `float` | `get(int index)` Get an entry at a particular index.
    `FloatList` | `getPercent()` Returns a normalized version of this array.
    `FloatList` | `getSubset(int start)`
    `FloatList` | `getSubset(int start, int num)`
    `boolean` | `hasValue(float value)`
    `int` | `index(float what)` Return the first index of a particular value.
    `void` | `insert(int index, float value)`
    `void` | `insert(int index, float[] values)`
    `void` | `insert(int index, FloatList list)`
    `Iterator<Float>` | `iterator()` Implemented this way so that we can use a FloatList in a for loop.
    `String` | `join(String separator)`
    `float` | `max()`
    `int` | `maxIndex()`
    `float` | `min()`
    `int` | `minIndex()`
    `void` | `mult(int index, float amount)`
    `void` | `print()`
    `float` | `remove(int index)` Remove an element from the specified index.
    `int` | `removeValue(int value)`
    `int` | `removeValues(int value)`
    `boolean` | `replaceValue(float value, float newValue)` Replace the first instance of a particular value
    `boolean` | `replaceValues(float value, float newValue)` Replace all instances of a particular value
    `void` | `resize(int length)`
    `void` | `reverse()`
    `void` | `set(int index, float what)` Set the entry at a particular index.
    `void` | `shuffle()` Randomize the order of the list elements.
    `void` | `shuffle(PApplet sketch)` Randomize the list order using the random() function from the specified sketch, allowing shuffle() to use its current randomSeed() setting.
    `int` | `size()` Get the length of the list.
    `void` | `sort()` Sorts the array in place.
    `void` | `sortReverse()` Reverse sort, orders values from highest to lowest
    `void` | `sub(int index, float amount)`
    `float` | `sum()`
    `String` | `toString()`
    `float[]` | `values()` Returns the actual array being used to store the data.

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FloatList

          public FloatList()

    - #### FloatList

          public FloatList(int length)

    - #### FloatList

          public FloatList(float[] list)

    - #### FloatList

          public FloatList(Iterable<Float> iter)

  - ### Method Detail

    - #### size

          public int size()

      Get the length of the list.

    - #### resize

          public void resize(int length)

    - #### clear

          public void clear()

      Remove all entries from the list.

    - #### get

          public float get(int index)

      Get an entry at a particular index.

    - #### set

          public void set(int index,
                 float what)

      Set the entry at a particular index. If the index is past the length of the list, it'll expand the list to accommodate, and fill the intermediate entries with 0s.

    - #### remove

          public float remove(int index)

      Remove an element from the specified index.

    - #### removeValue

          public int removeValue(int value)

    - #### removeValues

          public int removeValues(int value)

    - #### replaceValue

          public boolean replaceValue(float value,
                             float newValue)

      Replace the first instance of a particular value

    - #### replaceValues

          public boolean replaceValues(float value,
                              float newValue)

      Replace all instances of a particular value

    - #### append

          public void append(float value)

      Add a new entry to the list.

    - #### append

          public void append(float[] values)

    - #### append

          public void append(FloatList list)

    - #### insert

          public void insert(int index,
                    float value)

    - #### insert

          public void insert(int index,
                    float[] values)

    - #### insert

          public void insert(int index,
                    FloatList list)

    - #### index

          public int index(float what)

      Return the first index of a particular value.

    - #### hasValue

          public boolean hasValue(float value)

    - #### add

          public void add(int index,
                 float amount)

    - #### sub

          public void sub(int index,
                 float amount)

    - #### mult

          public void mult(int index,
                  float amount)

    - #### div

          public void div(int index,
                 float amount)

    - #### min

          public float min()

    - #### minIndex

          public int minIndex()

    - #### max

          public float max()

    - #### maxIndex

          public int maxIndex()

    - #### sum

          public float sum()

    - #### sort

          public void sort()

      Sorts the array in place.

    - #### sortReverse

          public void sortReverse()

      Reverse sort, orders values from highest to lowest

    - #### reverse

          public void reverse()

    - #### shuffle

          public void shuffle()

      Randomize the order of the list elements. Note that this does not obey the randomSeed() function in PApplet.

    - #### shuffle

          public void shuffle(PApplet sketch)

      Randomize the list order using the random() function from the specified sketch, allowing shuffle() to use its current randomSeed() setting.

    - #### copy

          public FloatList copy()

    - #### values

          public float[] values()

      Returns the actual array being used to store the data. For advanced users, this is the fastest way to access a large list. Suitable for iterating with a for() loop, but modifying the list will have terrible consequences.

    - #### iterator

          public Iterator<Float> iterator()

      Implemented this way so that we can use a FloatList in a for loop.
      Specified by:
        `iterator` in interface `Iterable<Float>`

    - #### array

          public float[] array()

      Create a new array with a copy of all the values.
      Returns:
        an array sized by the length of the list with each of the values.

    - #### array

          public float[] array(float[] array)

      Copy values into the specified array. If the specified array is null or not the same size, a new array will be allocated.
      Parameters:
        `array` -

    - #### getPercent

          public FloatList getPercent()

      Returns a normalized version of this array. Called getPercent() for consistency with the Dict classes. It's a getter method because it needs to returns a new list (because IntList/Dict can't do percentages or normalization in place on int values).

    - #### getSubset

          public FloatList getSubset(int start)

    - #### getSubset

          public FloatList getSubset(int start,
                            int num)

    - #### join

          public String join(String separator)

    - #### print

          public void print()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`