Documentation of 'processing.data.FloatDict' Java class
FloatDict
processing.data

Class FloatDict



  • public class FloatDict
    extends java.lang.Object
    A simple table class to use a String as a lookup for an float value.
    See Also:
    IntDict, StringDict
    • Constructor Summary

      Constructors 
      Constructor and Description
      FloatDict() 
      FloatDict(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.
      FloatDict(int length)
      Create a new lookup with a specific size.
      FloatDict(java.lang.Object[][] pairs)
      Constructor to allow (more intuitive) inline initialization, e.g.:
      FloatDict(java.lang.String[] keys, float[] values) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void add(java.lang.String key, float amount) 
      void clear()
      Remove all entries.
      FloatDict copy()
      Returns a duplicate copy of this object.
      void div(java.lang.String key, float amount) 
      float get(java.lang.String key)
      Return a value for the specified key.
      float get(java.lang.String key, float alternate) 
      FloatDict getPercent()
      Sum all of the values in this dictionary, then return a new FloatDict of each key, divided by the total sum.
      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.util.Iterator<java.lang.String> keyIterator() 
      java.lang.Iterable<java.lang.String> keys() 
      int maxIndex() 
      java.lang.String maxKey()
      The key for a max value; null if empty or everything is NaN (no max).
      float maxValue()
      The max value.
      int minIndex() 
      java.lang.String minKey() 
      float minValue() 
      void mult(java.lang.String key, float amount) 
      void print() 
      int remove(java.lang.String key) 
      java.lang.String removeIndex(int index) 
      void set(java.lang.String key, float 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 sortValues(boolean stable)
      Set true to ensure that the order returned is identical.
      void sortValuesReverse() 
      void sortValuesReverse(boolean stable) 
      void sub(java.lang.String key, float amount) 
      void swap(int a, int b) 
      java.lang.String toString() 
      float value(int index) 
      float[] valueArray()
      Create a new array and copy each of the values into it.
      float[] valueArray(float[] array)
      Fill an already-allocated array with the values (more efficient than creating a new array each time).
      java.util.Iterator<java.lang.Float> valueIterator() 
      java.lang.Iterable<java.lang.Float> 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

      • FloatDict

        public FloatDict()
      • FloatDict

        public FloatDict(int length)
        Create a new lookup with a specific size. This is more efficient than not specifying a size. Use it when you know the rough size of the thing you're creating.
      • FloatDict

        public FloatDict(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.
      • FloatDict

        public FloatDict(java.lang.String[] keys,
                         float[] values)
      • FloatDict

        public FloatDict(java.lang.Object[][] pairs)
        Constructor to allow (more intuitive) inline initialization, e.g.:
         new FloatDict(new Object[][] {
           { "key1", 1 },
           { "key2", 2 }
         });
         
    • 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()
      • keyIterator

        public java.util.Iterator<java.lang.String> keyIterator()
      • 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 float value(int index)
      • values

        public java.lang.Iterable<java.lang.Float> values()
      • valueIterator

        public java.util.Iterator<java.lang.Float> valueIterator()
      • valueArray

        public float[] valueArray()
        Create a new array and copy each of the values into it.
      • valueArray

        public float[] valueArray(float[] 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 float get(java.lang.String key)
        Return a value for the specified key.
      • get

        public float get(java.lang.String key,
                         float alternate)
      • set

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

        public boolean hasKey(java.lang.String key)
      • add

        public void add(java.lang.String key,
                        float amount)
      • sub

        public void sub(java.lang.String key,
                        float amount)
      • mult

        public void mult(java.lang.String key,
                         float amount)
      • div

        public void div(java.lang.String key,
                        float amount)
      • minIndex

        public int minIndex()
      • minKey

        public java.lang.String minKey()
      • minValue

        public float minValue()
      • maxIndex

        public int maxIndex()
      • maxKey

        public java.lang.String maxKey()
        The key for a max value; null if empty or everything is NaN (no max).
      • maxValue

        public float maxValue()
        The max value. (Or NaN if no entries or they're all NaN.)
      • index

        public int index(java.lang.String what)
      • 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]).
      • sortValues

        public void sortValues(boolean stable)
        Set true to ensure that the order returned is identical. Slightly slower because the tie-breaker for identical values compares the keys.
        Parameters:
        stable -
      • sortValuesReverse

        public void sortValuesReverse()
      • sortValuesReverse

        public void sortValuesReverse(boolean stable)
      • getPercent

        public FloatDict getPercent()
        Sum all of the values in this dictionary, then return a new FloatDict of each key, divided by the total sum. The total for all values will be ~1.0.
        Returns:
        a FloatDict with the original keys, mapped to their pct of the total
      • copy

        public FloatDict copy()
        Returns a duplicate copy of this object.
      • print

        public void print()
      • write

        public void write(java.io.PrintWriter writer)
        Write tab-delimited entries out to
        Parameters:
        writer -
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.