Reference for Processing version 1.2. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

HashMap

Examples
HashMap hm = new HashMap();

hm.put("Ava", 1);
hm.put("Cait", 35);
hm.put("Casey", 36);

Iterator i = hm.entrySet().iterator();  // Get an iterator

while (i.hasNext()) {
  Map.Entry me = (Map.Entry)i.next();
  print(me.getKey() + " is ");
  println(me.getValue());
}
Description A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only instead of accessing elements with a numeric index, a String is used. (If you are familiar with associative arrays from other languages, this is the same idea.) The above example covers basic use, but there's a more extensive example included with the Processing examples.

For a list of the numerous HashMap features, please read the Java reference description.
Constructor
HashMap()
HashMap(initialCapacity)
HashMap(initialCapacity, loadFactor)
HashMap(m)
Parameters
initialCapacity int: defines the initial capacity of the map, it's 16 by default
loadFactor float: the load factor for the map, the default is 0.75
m Map: gives the new HashMap the same mappings as this Map
Usage Web & Application
Updated on June 14, 2010 12:05:29pm EDT

Creative Commons License