-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathHashMap.xml
More file actions
95 lines (69 loc) · 2.61 KB
/
HashMap.xml
File metadata and controls
95 lines (69 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>HashMap</name>
<category>Data</category>
<subcategory>Composite</subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
import java.util.Map;
// Note the HashMap's "key" is a String and "value" is an Integer
HashMap<String,Integer> hm = new HashMap<String,Integer>();
// Putting key-value pairs in the HashMap
hm.put("Ava", 1);
hm.put("Cait", 35);
hm.put("Casey", 36);
// Using an enhanced loop to iterate over each entry
for (Map.Entry me : hm.entrySet()) {
print(me.getKey() + " is ");
println(me.getValue());
}
// We can also access values by their key
int val = hm.get("Casey");
println("Casey is " + val);
]]></code>
</example>
<description><![CDATA[
A <b>HashMap</b> stores a collection of objects, each referenced by a key. This is similar to an <b>Array</b>, only instead of accessing elements with a numeric index, a <b>String</b> 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. In addition, for simple pairings of Strings and integers, Strings and floats, or Strings and Strings, you can now use the simpler IntDict, FloatDict, and StringDict classes.<br />
<br />
For a list of the numerous <b>HashMap</b> features, please read the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html">Java reference description</a>.
]]></description>
<syntax></syntax>
<constructor>
HashMap&lt;Key, Value&gt;()
HashMap&lt;Key, Value&gt;(<c>initialCapacity</c>)
HashMap&lt;Key, Value&gt;(<c>initialCapacity</c>, <c>loadFactor</c>)
HashMap&lt;Key, Value&gt;(<c>m</c>)
</constructor>
<parameter>
<label>Key</label>
<description>Class Name: the data type for the HashMap's keys</description>
</parameter>
<parameter>
<label>Value</label>
<description>Class Name: the data type for the HashMap's values</description>
</parameter>
<parameter>
<label>initialCapacity</label>
<description>int: defines the initial capacity of the map; the default is 16</description>
</parameter>
<parameter>
<label>loadFactor</label>
<description>float: the load factor for the map; the default is 0.75</description>
</parameter>
<parameter>
<label>m</label>
<description>Map: gives the new HashMap the same mappings as this Map</description>
</parameter>
<returns></returns>
<related>
IntDict
FloatDict
StringDict
</related>
<availability>1.0</availability>
<type>Object</type>
<partof>PDE</partof>
<level>Extended</level>
</root>