processing.data

## Class IntList

- Object
- - IntList

- All Implemented Interfaces:
    Iterable<Integer>

      public class IntList
      extends Object
      implements Iterable<Integer>

  Helper class for a list of ints. 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:
    `FloatList`, `StringList`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IntList()`
    `IntList(int length)`
    `IntList(int[] source)`
    `IntList(Iterable<Integer> iter)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(int index, int amount)`
    `void` | `append(int value)` Add a new entry to the list.
    `void` | `append(int[] values)`
    `void` | `append(IntList list)`
    `int[]` | `array()` Create a new array with a copy of all the values.
    `int[]` | `array(int[] array)` Copy as many values as possible into the specified array.
    `void` | `clear()` Remove all entries from the list.
    `IntList` | `copy()`
    `void` | `div(int index, int amount)`
    `static IntList` | `fromRange(int stop)`
    `static IntList` | `fromRange(int start, int stop)`
    `int` | `get(int index)` Get an entry at a particular index.
    `FloatList` | `getPercent()` Returns a normalized version of this array.
    `IntList` | `getSubset(int start)`
    `IntList` | `getSubset(int start, int num)`
    `boolean` | `hasValue(int value)`
    `void` | `increment(int index)`
    `int` | `index(int what)` Return the first index of a particular value.
    `void` | `insert(int index, int[] values)`
    `void` | `insert(int index, IntList list)`
    `Iterator<Integer>` | `iterator()`
    `String` | `join(String separator)`
    `int` | `max()`
    `int` | `maxIndex()`
    `int` | `min()`
    `int` | `minIndex()`
    `void` | `mult(int index, int amount)`
    `int` | `remove(int index)` Remove an element from the specified index
    `int` | `removeValue(int value)`
    `int` | `removeValues(int value)`
    `void` | `resize(int length)`
    `void` | `reverse()`
    `void` | `set(int index, int 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, int amount)`
    `int` | `sum()`
    `String` | `toString()`
    `int[]` | `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

    - #### IntList

          public IntList()

    - #### IntList

          public IntList(int length)

    - #### IntList

          public IntList(int[] source)

    - #### IntList

          public IntList(Iterable<Integer> iter)

  - ### Method Detail

    - #### fromRange

          public static IntList fromRange(int stop)

    - #### fromRange

          public static IntList fromRange(int start,
                          int stop)

    - #### 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 int get(int index)

      Get an entry at a particular index.

    - #### set

          public void set(int index,
                 int 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 int remove(int index)

      Remove an element from the specified index

    - #### removeValue

          public int removeValue(int value)

    - #### removeValues

          public int removeValues(int value)

    - #### append

          public void append(int value)

      Add a new entry to the list.

    - #### append

          public void append(int[] values)

    - #### append

          public void append(IntList list)

    - #### insert

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

    - #### insert

          public void insert(int index,
                    IntList list)

    - #### index

          public int index(int what)

      Return the first index of a particular value.

    - #### hasValue

          public boolean hasValue(int value)

    - #### increment

          public void increment(int index)

    - #### add

          public void add(int index,
                 int amount)

    - #### sub

          public void sub(int index,
                 int amount)

    - #### mult

          public void mult(int index,
                  int amount)

    - #### div

          public void div(int index,
                 int amount)

    - #### min

          public int min()

    - #### minIndex

          public int minIndex()

    - #### max

          public int max()

    - #### maxIndex

          public int maxIndex()

    - #### sum

          public int 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 IntList copy()

    - #### values

          public int[] 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<Integer> iterator()

      Specified by:
        `iterator` in interface `Iterable<Integer>`

    - #### array

          public int[] 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 int[] array(int[] array)

      Copy as many values as possible into the specified array.
      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 IntList getSubset(int start)

    - #### getSubset

          public IntList getSubset(int start,
                          int num)

    - #### join

          public String join(String separator)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`