processing.data

## Class StringDict

- java.lang.Object
- - processing.data.StringDict

-     public class StringDict
      extends java.lang.Object

  A simple table class to use a String as a lookup for another String value.
  See Also:
    `IntDict`, `FloatDict`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringDict()`
    `StringDict(java.io.BufferedReader reader)` Read a set of entries from a Reader that has each key/value pair on a single line, separated by a tab.
    `StringDict(int length)` Create a new lookup pre-allocated to a specific length.
    `StringDict(java.lang.String[] keys, java.lang.String[] values)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Remove all entries.
    `StringDict` | `copy()` Returns a duplicate copy of this object.
    `java.lang.String` | `get(java.lang.String key)` Return a value for the specified key.
    `java.lang.String` | `get(java.lang.String key, java.lang.String alternate)`
    `boolean` | `hasKey(java.lang.String key)`
    `int` | `index(java.lang.String what)`
    `java.lang.String` | `key(int index)`
    `java.lang.String[]` | `keyArray()` Return a copy of the internal keys array.
    `java.lang.String[]` | `keyArray(java.lang.String[] outgoing)`
    `java.lang.Iterable<java.lang.String>` | `keys()`
    `void` | `print()`
    `int` | `remove(java.lang.String key)`
    `java.lang.String` | `removeIndex(int index)`
    `void` | `set(java.lang.String key, java.lang.String amount)`
    `int` | `size()`
    `void` | `sortKeys()` Sort the keys alphabetically (ignoring case).
    `void` | `sortKeysReverse()`
    `void` | `sortValues()` Sort by values in descending order (largest value will be at [0]).
    `void` | `sortValuesReverse()`
    `void` | `swap(int a, int b)`
    `java.lang.String` | `toString()`
    `java.lang.String` | `value(int index)`
    `java.lang.String[]` | `valueArray()` Create a new array and copy each of the values into it.
    `java.lang.String[]` | `valueArray(java.lang.String[] array)` Fill an already-allocated array with the values (more efficient than creating a new array each time).
    `java.lang.Iterable<java.lang.String>` | `values()`
    `void` | `write(java.io.PrintWriter writer)` Write tab-delimited entries out to

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### StringDict

          public StringDict()

    - #### StringDict

          public StringDict(int length)

      Create a new lookup pre-allocated to a specific length. This will not change the size(), but is more efficient than not specifying a length. Use it when you know the rough size of the thing you're creating.

    - #### StringDict

          public StringDict(java.io.BufferedReader reader)

      Read a set of entries from a Reader that has each key/value pair on a single line, separated by a tab.

    - #### StringDict

          public StringDict(java.lang.String[] keys,
                    java.lang.String[] values)

  - ### Method Detail

    - #### size

          public int size()

    - #### clear

          public void clear()

      Remove all entries.

    - #### key

          public java.lang.String key(int index)

    - #### keys

          public java.lang.Iterable<java.lang.String> keys()

    - #### keyArray

          public java.lang.String[] keyArray()

      Return a copy of the internal keys array. This array can be modified.

    - #### keyArray

          public java.lang.String[] keyArray(java.lang.String[] outgoing)

    - #### value

          public java.lang.String value(int index)

    - #### values

          public java.lang.Iterable<java.lang.String> values()

    - #### valueArray

          public java.lang.String[] valueArray()

      Create a new array and copy each of the values into it.

    - #### valueArray

          public java.lang.String[] valueArray(java.lang.String[] array)

      Fill an already-allocated array with the values (more efficient than creating a new array each time). If 'array' is null, or not the same size as the number of values, a new array will be allocated and returned.

    - #### get

          public java.lang.String get(java.lang.String key)

      Return a value for the specified key.

    - #### get

          public java.lang.String get(java.lang.String key,
                             java.lang.String alternate)

    - #### set

          public void set(java.lang.String key,
                 java.lang.String amount)

    - #### index

          public int index(java.lang.String what)

    - #### hasKey

          public boolean hasKey(java.lang.String key)

    - #### remove

          public int remove(java.lang.String key)

    - #### removeIndex

          public java.lang.String removeIndex(int index)

    - #### swap

          public void swap(int a,
                  int b)

    - #### sortKeys

          public void sortKeys()

      Sort the keys alphabetically (ignoring case). Uses the value as a tie-breaker (only really possible with a key that has a case change).

    - #### sortKeysReverse

          public void sortKeysReverse()

    - #### sortValues

          public void sortValues()

      Sort by values in descending order (largest value will be at [0]).

    - #### sortValuesReverse

          public void sortValuesReverse()

    - #### copy

          public StringDict copy()

      Returns a duplicate copy of this object.

    - #### write

          public void write(java.io.PrintWriter writer)

      Write tab-delimited entries out to
      Parameters:
        `writer` -

    - #### print

          public void print()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`