1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica
; min-height: 16.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0021e7}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #ad140d}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 29.0px; font: 12.0px Helvetica
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #001bb9}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
21 span
.s1
{font: 12.0px Helvetica
}
22 span
.s2
{color: #001bb9}
23 span
.s3
{color: #000000}
24 span
.s4
{text-decoration: underline
}
25 span
.s5
{color: #2c7014}
26 span
.Apple-tab-span
{white-space:pre
}
30 <p class=
"p1"><b>MultiLevelIdentityDictionary
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b><span class=
"s1"><b>tree of dictionaries
</b></span></p>
31 <p class=
"p2"><br></p>
32 <p class=
"p3"><b>Inherits from:
</b><a href=
"../Core/Object.html"><span class=
"s2"><b>Object
</b></span></a><b> :
</b><a href=
"Collection.html"><span class=
"s2"><b>Collection
</b></span></a></p>
33 <p class=
"p4"><br></p>
34 <p class=
"p2"><br></p>
35 <p class=
"p3">A tree of IdentityDictionaries.
<span class=
"Apple-converted-space"> </span>Addresses within the tree are specified with a series of keys.
<span class=
"Apple-converted-space"> </span><a href=
"Library.html"><span class=
"s2">Library
</span></a> is its most useful subclass.
</p>
36 <p class=
"p2"><br></p>
37 <p class=
"p5"><span class=
"s3">see also:
<a href=
"IdentityDictionary.html"><span class=
"s4">IdentityDictionary
</span></a></span></p>
38 <p class=
"p2"><br></p>
39 <p class=
"p2"><br></p>
40 <p class=
"p3"><b>at(key1,key2 ... keyN)
</b></p>
41 <p class=
"p3"><span class=
"Apple-tab-span"> </span>retrieves a leaf node or nil if not found.
</p>
42 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
43 <p class=
"p3"><b>put(key1,key2 ... keyN, item)
</b></p>
44 <p class=
"p3"><span class=
"Apple-tab-span"> </span>puts the item as a leaf node, internally creating new branches as needed to accommodate the list of keys.
</p>
45 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
46 <p class=
"p3"><b>choose
</b></p>
47 <p class=
"p3"><span class=
"Apple-tab-span"> </span>choose a branch at each level, descend the tree until a leaf is chosen.
</p>
48 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
49 <p class=
"p3"><b>choose(key1,key2 ... keyN)
</b></p>
50 <p class=
"p3"><span class=
"Apple-tab-span"> </span>starting at an address within the tree, descend the tree until a leaf is chosen.
</p>
51 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
52 <p class=
"p3"><b>putTree
</b>(key1,[
</p>
53 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>key2a, item1-
2a,
</p>
54 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>key2b, item1-
2b,
</p>
55 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
</p>
56 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>key3, item1-
3</p>
57 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>]
</span>// etc...
</p>
58 <p class=
"p3"><span class=
"Apple-tab-span"> </span>]);
</p>
59 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
60 <p class=
"p3"><span class=
"Apple-tab-span"> </span>A way to insert objects into the tree with a syntax similar to the organization of the tree
</p>
61 <p class=
"p3"><span class=
"Apple-tab-span"> </span>itself.
</p>
62 <p class=
"p2"><br></p>
63 <p class=
"p3"><b>removeAt(key1,key2 ... keyN)
</b></p>
64 <p class=
"p3"><span class=
"Apple-tab-span"> </span>Remove only the item located by the path.
</p>
65 <p class=
"p2"><br></p>
66 <p class=
"p3"><b>removeEmptyAt(key1,key2 ... keyN)
</b></p>
67 <p class=
"p7">Remove the item located by the path. This might make the item's parent dictionary empty. In that case, it will remove the parent and continue up the chain, removing empty dictionaries as it goes. This is slower but cleaner.
</p>
68 <p class=
"p2"><br></p>
69 <p class=
"p2"><br></p>
70 <p class=
"p8">// Example of the difference between removeAt and removeEmptyAt
</p>
71 <p class=
"p9"><br></p>
72 <p class=
"p10"><span class=
"s3">m =
</span>MultiLevelIdentityDictionary
<span class=
"s3">.new;
</span></p>
73 <p class=
"p11">m.put(
<span class=
"s5">\a
</span>,
<span class=
"s5">\b
</span>,
<span class=
"s5">\c
</span>,
1);
</p>
74 <p class=
"p9"><br></p>
75 <p class=
"p11">m.removeAt(
<span class=
"s5">\a
</span>,
<span class=
"s5">\b
</span>,
<span class=
"s5">\c
</span>);
</p>
76 <p class=
"p8"><span class=
"s3">m
<span class=
"Apple-tab-span"> </span></span>// note, \a and \b dictionaries remain
</p>
77 <p class=
"p9"><br></p>
78 <p class=
"p11">m.put(
<span class=
"s5">\a
</span>,
<span class=
"s5">\b
</span>,
<span class=
"s5">\c
</span>,
2);
</p>
79 <p class=
"p11">m.removeEmptyAt(
<span class=
"s5">\a
</span>,
<span class=
"s5">\b
</span>,
<span class=
"s5">\c
</span>);
</p>
80 <p class=
"p8"><span class=
"s3">m
<span class=
"Apple-tab-span"> </span></span>// now the entire MultiLevelIdentityDictionary is empty
</p>
81 <p class=
"p2"><br></p>