forked from processing-js/processing-js.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashMap.html
More file actions
73 lines (61 loc) · 2.06 KB
/
Copy pathHashMap.html
File metadata and controls
73 lines (61 loc) · 2.06 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
---
layout: default
---
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
<tr class="name-row">
<th scope="row">Name</th>
<td><h3>HashMap</h3></td>
</tr>
<tr class="">
<th scope="row">Examples</th>
<td><div class="example"><pre>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());
}</pre></div></td>
</tr>
<tr class="">
<th scope="row">Description</th>
<td><p>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. </p>
<p>For a list of the numerous HashMap features, please read the <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html">Java reference description</a>.</p></td>
</tr>
<tr class="">
<th scope="row">Constructor</th>
<td><pre>HashMap()</pre><br>
<pre>HashMap(<kbd>initialCapacity</kbd>)</pre><br>
<pre>HashMap(<kbd>initialCapacity</kbd>,<kbd>loadFactor</kbd>)</pre><br>
<pre>HashMap(m)</pre><br>
</td>
</tr>
<tr class="">
<th scope="row">Parameters</th>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row">initialCapacity</th>
<td>int: defines the initial capacity of the map, it's 16 by default</td>
</tr>
<tr class="">
<th scope="row">loadFactor</th>
<td>float: the load factor for the map, the default is 0.75</td>
</tr>
<tr class="">
<th scope="row">m</th>
<td>Map: gives the new HashMap the same mappings as this Map
</td>
</tr>
</table>
</td>
</tr>
<tr class="">
<th scope="row">Usage</th>
<td>Web & Application</td>
</tr>
</table>