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=
"1038.32">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.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: 9.0px Monaco
; min-height: 12.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0000ee}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #737373}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #007300}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000; min-height: 12.0px}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
; min-height: 17.0px}
24 p
.p15
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
25 p
.p16
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #bf0000}
26 p
.p17
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
27 p
.p18
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Monaco
; min-height: 16.0px}
28 p
.p19
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #007300}
29 p
.p20
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #007300; min-height: 12.0px}
30 p
.p21
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; color: #0000ee}
31 p
.p22
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
32 p
.p23
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #000000}
33 p
.p24
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #000000; min-height: 12.0px}
34 p
.p25
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #0000bf}
35 span
.s1
{font: 18.0px Helvetica
}
36 span
.s2
{color: #0000bf}
37 span
.s3
{color: #000000}
38 span
.s4
{text-decoration: underline
}
39 span
.s5
{color: #bf0000}
40 span
.s6
{color: #007300}
41 span
.s7
{color: #737373}
42 span
.s8
{font: 12.0px Helvetica
}
43 span
.s9
{font: 9.0px Monaco
}
44 span
.s10
{font: 9.0px Monaco
; color: #007300}
45 span
.s11
{font: 12.0px Monaco
}
46 span
.s12
{color: #1135f9}
47 span
.s13
{font: 14.0px Helvetica
}
48 span
.s14
{font: 12.0px Helvetica
; color: #000000}
49 span
.s15
{color: #102ac3}
50 span
.s16
{font: 9.0px Monaco
; color: #000000}
51 span
.s17
{color: #1738f5}
52 span
.s18
{color: #008225}
53 span
.Apple-tab-span
{white-space:pre
}
57 <p class=
"p1"><span class=
"s1"><b>Dictionary
</b></span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>associative collection mapping keys to values
</b></p>
58 <p class=
"p2"><br></p>
59 <p class=
"p1"><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><b> :
</b><a href=
"Set.html"><span class=
"s2"><b>Set
</b></span></a></p>
60 <p class=
"p3"><br></p>
61 <p class=
"p1">A Dictionary is an associative collection mapping keys to values.
</p>
62 <p class=
"p1">Two keys match if they are
<b>equal
</b>. (i.e. == returns true.)
</p>
63 <p class=
"p2"><br></p>
64 <p class=
"p1">The contents of a Dictionary are
<b>unordered
</b>. You must not depend on the order of items in a Dictionary.
</p>
65 <p class=
"p1">You must only rely on equality for the keys (e.g. symbols are ok, strings not). For identity matching see:
<a href=
"IdentityDictionary.html"><span class=
"s2">IdentityDictionary
</span></a>.
</p>
66 <p class=
"p2"><br></p>
67 <p class=
"p4"><span class=
"s3"><b>See also
</b>:
<a href=
"Environment.html"><span class=
"s4">Envirownment
</span></a>,
<a href=
"Event.html"><span class=
"s4">Event
</span></a></span></p>
68 <p class=
"p2"><br></p>
69 <p class=
"p2"><br></p>
70 <p class=
"p5"><b>The Difference between Dictionary, IdentityDictionary, Environment, and Event
</b></p>
71 <p class=
"p2"><br></p>
72 <p class=
"p1">Often, the subclass
<a href=
"Event.html"><span class=
"s2">Event
</span></a> is used as an IdentityDictionary, because there is a syntactical shortcut:
</p>
73 <p class=
"p2"><br></p>
74 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a = (foo:
7);
</span>// return a new Event.
</p>
75 <p class=
"p7"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>a.put(
<span class=
"s6">\foo
</span>,
2.718);
</p>
76 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a.at(
<span class=
"s6">\foo
</span>);
</p>
77 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a[
</span><span class=
"s6">\foo
</span><span class=
"s3">] =
3.5;
</span>// different syntax for put
</p>
78 <p class=
"p2"><br></p>
79 <p class=
"p1">Event, Environment and IdentityDictionary differ mainly insofar from Dictionary as the
<b>keys
</b> are taken to be identical (===) objects (see
<a href=
"IdentityDictionary.html"><span class=
"s2">IdentityDictionary
</span></a>), instead of equal (==) objects. By consequence, the subclasses are also faster for indexing. Apart from this, the subclasses add specific functionality only. Because of its very common usage, the examples often use the shortcut for the subclass Event.
</p>
80 <p class=
"p2"><br></p>
81 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// preliminary identity and equality of strings and symbols
</p>
82 <p class=
"p8"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>"hello"<span class=
"s3"> ==
</span>"hello"<span class=
"s3"> </span><span class=
"s5">// true, but
</span></p>
83 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s7">"hello"</span><span class=
"s3"> ===
</span><span class=
"s7">"hello"</span><span class=
"s3"> </span>// false. However:
</p>
84 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\hello
<span class=
"s3"> ===
</span>\hello
<span class=
"s3"> </span><span class=
"s5">// true
</span></p>
85 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
86 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>// compare
</p>
87 <p class=
"p6"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Dictionary
</span><span class=
"s3">[
</span><span class=
"s7">"hello"</span><span class=
"s3"> -
> 0,
</span><span class=
"s7">"hello"</span><span class=
"s3"> -
> 1];
</span>// Dictionary[ (hello -
> 1) ]
</p>
88 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</span><span class=
"s7">"hello"</span><span class=
"s3">:
0,
</span><span class=
"s7">"hello"</span><span class=
"s3">:
1);
</span>// (
"hello":
1,
"hello":
0 )
</p>
89 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
90 <p class=
"p6"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// for symbols as keys, the behaviour is identical:
</p>
91 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Dictionary
</span>[
<span class=
"s6">\hello
</span> -
> 1,
<span class=
"s6">\hello
</span> -
> 0];
</p>
92 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
<span class=
"s6">\hello
</span>:
1,
<span class=
"s6">\hello
</span>:
0 )
</p>
93 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
94 <p class=
"p2"><br></p>
95 <p class=
"p13"><b>Creation / Class Methods
</b></p>
96 <p class=
"p12"><br></p>
97 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>*new(n)
</b></p>
98 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Creates a Dictionary with an initial capacity for n key value mappings.
</p>
99 <p class=
"p12"><br></p>
100 <p class=
"p14"><br></p>
101 <p class=
"p13"><b>Adding and Removing
</b><span class=
"s8"><span class=
"Apple-tab-span"> </span></span></p>
102 <p class=
"p15"><b><span class=
"Apple-tab-span"> </span></b></p>
103 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>add(anAssociation)
</b></p>
104 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Add anAssociation to the Dictionary.
<span class=
"Apple-converted-space"> </span>If the key value pair already exists in the Dictionary, the key's value will be replaced.
</p>
105 <p class=
"p15"><br></p>
106 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</p>
107 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d =
<span class=
"s2">Dictionary
</span>.new;
</p>
108 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.add(
<span class=
"s6">\monkey
</span> -
> 0).postln;
</p>
109 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// Add robot as a key with a value of
1</p>
110 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.add(
<span class=
"s6">\robot
</span> -
> 1).postln;
</p>
111 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// Replaces the value for the key monkey with
2</p>
112 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.add(
<span class=
"s6">\monkey
</span> -
> 2).postln;
</p>
113 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
114 <p class=
"p15"><br></p>
115 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>put(key, obj)
</b></p>
116 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Associate two objects and add them to the Dictionary.
</p>
117 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>key
</b> - key to associate with object. THis can be any objects, but is often a
<a href=
"../Core/Symbol.html"><span class=
"s2">Symbol
</span></a>.
</p>
118 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>obj
</b><span class=
"Apple-converted-space"> </span>- an object
</p>
119 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
120 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d =
<span class=
"s2">Dictionary
</span>.new;
</p>
121 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.put(
<span class=
"s7">"abc"</span>,
10);
</p>
122 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
123 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// using an event:
</p>
124 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = ();
</p>
125 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.put(
<span class=
"s7">"abc"</span>,
10);
</p>
126 <p class=
"p15"><br></p>
127 <p class=
"p5"><span class=
"Apple-tab-span"> </span><b>removeAt(key)
</b></p>
128 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Remove the key and the value associated with it from the Dictionary.
</p>
129 <p class=
"p15"><br></p>
130 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (monkey:
99);
</p>
131 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.removeAt(
<span class=
"s6">\monkey
</span>);
</p>
132 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
133 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>putAll(... dictionaries)
</b></p>
134 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Add all items of each argument to the dictionary.
</p>
135 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>dictionaries
</b> - any Object that responds to keysValuesDo (usually a Dictionary).
</p>
136 <p class=
"p15"><br></p>
137 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = ();
</p>
138 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.putAll(
<span class=
"s2">Dictionary
</span>[
<span class=
"s6">\hello
</span> -
> 9,
<span class=
"s6">\whello
</span> -
> <span class=
"s7">"world"</span>],
<span class=
"s2">Dictionary
</span>[
<span class=
"s7">"abd"</span> -
> 6]);
</p>
139 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
140 <p class=
"p12"><span class=
"Apple-tab-span"> </span></p>
141 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>putPairs(pairs)
</b></p>
142 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Add all items to the dictionary, using them as key and value pairwise
</p>
143 <p class=
"p15"><br></p>
144 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = ();
</p>
145 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.putPairs(
<span class=
"s6">\hello
</span>,
10,
<span class=
"s6">\whello
</span>,
<span class=
"s7">"lord"</span>,
<span class=
"s7">"abc"</span>,
7);
</p>
146 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
147 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
148 <p class=
"p17"><b>Accessing:
</b></p>
149 <p class=
"p18"><br></p>
150 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>at(key)
</b></p>
151 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Access the value associated with the key.
</p>
152 <p class=
"p18"><br></p>
153 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (robot:
99);
</p>
154 <p class=
"p16"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>// Get the value associated with key
</p>
155 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d.at(
<span class=
"s6">\robot
</span>);
</p>
156 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d[
</span><span class=
"s6">\robot
</span><span class=
"s3">];
</span>// different syntax, same behaviour
</p>
157 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// Key doesn't exist: return
<a href=
"../Core/Nil.html"><span class=
"s2">Nil
</span></a></p>
158 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d.at(
<span class=
"s6">\monkey
</span>);
</p>
159 <p class=
"p12"><span class=
"Apple-tab-span"> </span></p>
160 <p class=
"p5"><span class=
"s10"><span class=
"Apple-tab-span"> </span></span><b>keys
</b></p>
161 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return a
<a href=
"Set.html"><span class=
"s2">Set
</span></a> of all keys.
</p>
162 <p class=
"p18"><br></p>
163 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (hello:
9, whello:
<span class=
"s7">"world"</span>);
</p>
164 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d.keys;
</p>
165 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
166 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>values
</b></p>
167 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return a
<a href=
"List.html"><span class=
"s2">List
</span></a> of all values.
</p>
168 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
169 <p class=
"p11"><span class=
"s11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (hello:
9, whello:
<span class=
"s7">"world"</span>);
</p>
170 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d.values;
</p>
171 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
172 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>atAll(... keys)
</b></p>
173 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Return an array of all values for the given keys.
</p>
174 <p class=
"p15"><br></p>
175 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (hello:
9, whello:
<span class=
"s7">"world"</span>, z:
99, c:
0.33);
</p>
176 <p class=
"p19"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.atAll([
</span>\hello
<span class=
"s3">,
</span>\z
<span class=
"s3">,
</span>\hello
<span class=
"s3">,
</span>\c, \whello
<span class=
"s3">]);
</span></p>
177 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
178 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>getPairs
</b></p>
179 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Return an array with all keys and values pairwise.
</p>
180 <p class=
"p15"><br></p>
181 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (hello:
9, whello:
77, z:
99);
</p>
182 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.getPairs;
</p>
183 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
184 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>associationAt(key)
</b></p>
185 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Access the
<a href=
"Association.html"><span class=
"s2">Association
</span></a> that has the given key.
</p>
186 <p class=
"p18"><br></p>
187 <p class=
"p16"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>// Get the value associated with key
</p>
188 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (robot:
99);
</p>
189 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d.associationAt(
<span class=
"s6">\robot
</span>);
</p>
190 <p class=
"p20"><br></p>
191 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>findKeyForValue(argValue)
</b></p>
192 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Try to find a given value and return its key.
</p>
193 <p class=
"p18"><br></p>
194 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (hello:
1, whello:
1976);
</p>
195 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.findKeyForValue(
1);
</p>
196 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
197 <p class=
"p18"><br></p>
198 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>matchAt(item)
</b></p>
199 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The dictionary's keys are used as conditions against which the arbitrary item is matched.
</p>
200 <p class=
"p21"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>see:
</b><a href=
"../interfaces/matchItem.html"><b>matchItem
</b></a><b><span class=
"Apple-converted-space"> </span></b></span></p>
201 <p class=
"p15"><br></p>
202 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>Note
</b>: if an item matches multiple criteria, the value returned is arbitrary. This is because a dictionary is an unordered collection. It's the user's responsibility to make sure that criteria are mutually exclusive.
</p>
203 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
204 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>If the key is an object, the item will be matched by identity (if key === item, the value will be returned).
<span class=
"Apple-converted-space"> </span></p>
205 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>If the key is a collection, the item is matched if it's contained in the collection.
<span class=
"Apple-converted-space"> </span></p>
206 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>If the key is a function, the function is evaluated with the item as an argument and the item is matched if the function returns true.
</p>
207 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
208 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s9">(
</span></p>
209 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d =
<span class=
"s2">(
</span></p>
210 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0:
<span class=
"s6">\zero
</span>,
</p>
211 <p class=
"p19"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\abc
<span class=
"s3">:
</span>\alpha
<span class=
"s3">,
</span></p>
212 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
1,
2,
3,
5,
8,
13,
21]:
<span class=
"s6">\fibonacci
</span>,
</p>
213 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>{
</span><span class=
"s2">|x|
</span><span class=
"s3"> try { x.even } }:
</span><span class=
"s6">\even
</span>// try is needed because argument might not be a number
</p>
214 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
215 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
216 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
217 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.matchAt(
0)
</p>
218 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.matchAt(
1)
</p>
219 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.matchAt(
2)
<span class=
"Apple-converted-space"> </span></span>// matches both 'fibonacci' and 'even', either may be returned
</p>
220 <p class=
"p11"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d.matchAt(
4)
</p>
221 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.matchAt(
<span class=
"s6">\abc
</span>)
</p>
222 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
223 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>trueAt(key)
</b></p>
224 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Returns true if the item at the key is true, otherwise false.This method is also valid in
<a href=
"../Core/Object.html"><span class=
"s12">Object
</span></a><span class=
"s12">.
</span></p>
225 <p class=
"p12"><br></p>
226 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>falseAt(key)
</b></p>
227 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Returns false if the item at the key is not true, otherwise true. This method is inherited from
<a href=
"../Core/Object.html"><span class=
"s12">Object
</span></a>.
</p>
228 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
229 <p class=
"p12"><br></p>
230 <p class=
"p12"><br></p>
231 <p class=
"p17"><b>Iteration/Enumeration
</b></p>
232 <p class=
"p22"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
233 <p class=
"p5"><span class=
"s13"><b><span class=
"Apple-tab-span"> </span></b></span>Most methods for iteration work analogously to Dictionary's superclasses, see e.g.
<a href=
"Collection.html"><span class=
"s2">Collection
</span></a>.
<span class=
"Apple-converted-space"> </span></p>
234 <p class=
"p15"><span class=
"Apple-tab-span"> </span></p>
235 <p class=
"p5"><span class=
"Apple-tab-span"> </span><b>do(func)
</b></p>
236 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>collect(func)
</b></p>
237 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>reject(func)
</b></p>
238 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>select(func)
</b></p>
239 <p class=
"p15"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
240 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// do, collect, reject, select
</p>
241 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d =
<span class=
"s2">Dictionary
</span>[
<span class=
"s6">\a
</span> -
> <span class=
"s7">"hello"</span>,
<span class=
"s6">\b
</span> -
> <span class=
"s7">"robot"</span>,
<span class=
"s6">\c
</span> -
> [
1,
2,
3]];
</p>
242 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (a:
<span class=
"s7">"hello"</span>, b:
<span class=
"s7">"robot"</span>, c: [
1,
2,
3]);
<span class=
"s5">// equivalent
</span></p>
243 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.do {
<span class=
"s2">|item, i|
</span> [item, i].postln };
<span class=
"Apple-tab-span"> </span></p>
244 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.collect {
<span class=
"s2">|item|
</span> item +
100 };
<span class=
"Apple-tab-span"> </span></p>
245 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.reject {
<span class=
"s2">|item|
</span> item.size
> 4 };
</p>
246 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.select {
<span class=
"s2">|item|
</span> item.size
> 4 };
<span class=
"Apple-tab-span"> </span></p>
247 <p class=
"p12"><br></p>
248 <p class=
"p12"><br></p>
249 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>keysValuesDo(function)
</b></p>
250 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Iterate over the associations, and evaluate the function for each, passing key and value as argument.
</p>
251 <p class=
"p15"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
252 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (a:
<span class=
"s7">"hello"</span>, b:
<span class=
"s7">"robot"</span>, c: [
1,
2,
3]);
</p>
253 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.keysValuesDo {
<span class=
"s2">|key, value|
</span> postln(
<span class=
"s7">"the key: "</span> ++ key ++
<span class=
"s7">" the value: "</span> ++ value) };
</p>
254 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
255 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>keysValuesChange(function)
</b></p>
256 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Iterate over the associations, and evaluate the function for each, passing key and value as argument. Replace the value with the return value from the function (similar to
<b>collect
</b>, but modifies the dictionary i
<b>n place
</b>)
</p>
257 <p class=
"p15"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
258 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (a:
<span class=
"s7">"hello"</span>, b:
<span class=
"s7">"robot"</span>, c: [
1,
2,
3]);
</p>
259 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.keysValuesChange {
<span class=
"s2">|key, value|
</span> <span class=
"s7">"the key: "</span> ++ key ++
<span class=
"s7">" the value: "</span> ++ value };
</p>
260 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d;
</p>
261 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
262 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>keysDo(function)
</b></p>
263 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Iterate over the associations, and evaluate the function for each, passing key as argument.
</p>
264 <p class=
"p15"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
265 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (a:
<span class=
"s7">"hello"</span>, b:
<span class=
"s7">"robot"</span>, c: [
1,
2,
3]);
</p>
266 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.keysDo {
<span class=
"s2">|key|
</span> postln(
<span class=
"s7">"the key: "</span> ++ key) };
</p>
267 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
268 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>associationsDo(function)
</b></p>
269 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Iterate over the associations, and evaluate the function for each.
</p>
270 <p class=
"p15"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
271 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (a:
<span class=
"s7">"hello"</span>, b:
<span class=
"s7">"robot"</span>, c: [
1,
2,
3]);
</p>
272 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.associationsDo {
<span class=
"s2">|assoc|
</span> postln(
<span class=
"s7">"the association: "</span> ++ assoc) };
</p>
273 <p class=
"p12"><span class=
"Apple-tab-span"> </span></p>
274 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>pairsDo(function)
</b></p>
275 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Iterate over the associations, and evaluate the function for each, passing key and value as argument.
</p>
276 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Identical to
<b>keysValuesDo
</b></p>
277 <p class=
"p15"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
278 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span>invert
</b></p>
279 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return a new dictionary with all the values as keys and vice versa.
</p>
280 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
281 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (a:
<span class=
"s7">"hello"</span>, b:
<span class=
"s7">"robot"</span>, c: [
1,
2,
3]);
</p>
282 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.invert;
</p>
283 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
284 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
285 <p class=
"p17"><b>Other instance methods:
</b></p>
286 <p class=
"p12"><br></p>
287 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>order(func)
</b></p>
288 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return an array of keys which corresponds to the order of the values of the dictionary.
</p>
289 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
290 <p class=
"p11"><span class=
"s8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (a:
<span class=
"s7">5</span>, b:
<span class=
"s7">7</span>, c:
1, d:
0);
</p>
291 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.order;
</p>
292 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.atAll(d.order)
</span>// returns items in order
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
293 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
294 <p class=
"p12"><br></p>
295 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>powerset
</b></p>
296 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return the set of all subsets: here an array of all sub-dictionaries.
</p>
297 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
298 <p class=
"p11"><span class=
"s8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (a:
5, b:
7, c:
1, d:
0);
</p>
299 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.powerset;
</p>
300 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
301 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
302 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>merge(that, func, fill)
</b></p>
303 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Combine two dictionaries into a new one by applying a function to each value. If
<b>fill
</b> is true (default: true), values missing from one of them are kept as they are.
</p>
304 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
305 <p class=
"p23"><span class=
"s14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (a:
5, b:
7, d:
0);
</p>
306 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>e = (a:
3, b: -
3, c:
1);
</p>
307 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">merge
</span>(d, e, {
<span class=
"s15">|a, b|
</span> a + b });
</p>
308 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">merge
</span>(d, e, {
<span class=
"s15">|a, b|
</span> a + b },
<span class=
"s15">false
</span>);
</p>
309 <p class=
"p24"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
310 <p class=
"p24"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
311 <p class=
"p5"><span class=
"s16"><span class=
"Apple-tab-span"> </span></span><b>blend(that, blend, fill, specs)
</b></p>
312 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Blend two dictionaries into a new one by interpolating each value -
<b>blend
</b> is the blend ratio. If
<b>fill
</b> is true (default: true), values missing from one of them are kept as they are,
<b>specs
</b> is a dictionary of
<a href=
"../Control/Spec.html"><span class=
"s17">Spec
</span></a><span class=
"s17">s
</span> that are apples dto each before blending.
<span class=
"Apple-converted-space"> </span></p>
313 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
314 <p class=
"p23"><span class=
"s14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (a:
5, b:
7, d:
0);
</p>
315 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>e = (a:
3, b: -
3, c:
1);
</p>
316 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>blend(d, e,
0.3);
</p>
317 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>blend(d, e,
0.3,
<span class=
"s15">false
</span>);
</p>
318 <p class=
"p24"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
319 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (a:
500, b:
0.001);
</p>
320 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>e = (a:
300, b:
0.1);
</p>
321 <p class=
"p23"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>blend(d, e,
0.3, specs: (a:
<span class=
"s18">\freq
</span>, b:
<span class=
"s18">\rq
</span>));
</p>
322 <p class=
"p12"><br></p>
323 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
324 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>asSortedArray
</b></p>
325 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return the values in a sorted array of key value pairs
</p>
326 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
327 <p class=
"p11"><span class=
"s8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (a:
5, b:
7, c:
1, d:
0);
</p>
328 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.asSortedArray;
</p>
329 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
330 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>asKeyValuePairs
</b></p>
331 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Return the values in an array of alternating key value pairs
</p>
332 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
333 <p class=
"p11"><span class=
"s8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>d = (a:
5, b:
7, c:
1, d:
0);
</p>
334 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.asKeyValuePairs;
</p>
335 <p class=
"p12"><span class=
"Apple-tab-span"> </span></p>
336 <p class=
"p5"><span class=
"s9"><span class=
"Apple-tab-span"> </span></span><b>embedInStream(event)
</b></p>
337 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>If the event is not nil, yields a copy, with all the elements of the receiver.
</p>
338 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>See also
<a href=
"Event.html"><span class=
"s2">Event
</span></a>.
</p>
339 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
340 <p class=
"p16"><span class=
"s14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// write a generator for dictionaries
</p>
341 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</p>
342 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (
</p>
343 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a:
5, b:
7, c:
1,
</p>
344 <p class=
"p25"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>rout:
</span>Routine
<span class=
"s3"> {
</span>|inval|
</p>
345 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>inf.do { |i|
</p>
346 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>var event = d.copy.put(\count, i);
</p>
347 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>inval = event.embedInStream(inval)
<span class=
"Apple-converted-space"> </span></p>
348 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}
</p>
349 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}
</p>
350 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
351 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
352 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
353 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// draw new values
</p>
354 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.rout.((z:
999));
</p>
355 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.rout.((z:
1, a:
0));
</p>
356 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d.rout.(());
</p>
357 <p class=
"p12"><br></p>
358 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
359 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// sound example
</p>
360 <p class=
"p16"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// this also allows to use events or dictionaries in patterns directly:
</p>
361 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</p>
362 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d = (freq:
402, dur:
0.3);
</p>
363 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Pseq
</span>([
</p>
364 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d,
</p>
365 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(freq:
300, dur:
0.3),
</p>
366 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d,
</p>
367 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(freq: [
400,
770,
800], dur:
1),
</p>
368 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d,
</p>
369 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(freq:
451, dur:
0.33)
</p>
370 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>],
<span class=
"s2">inf
</span>).play;
</p>
371 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
372 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
373 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d[
<span class=
"s6">\freq
</span>] = [
900,
1002,
1102];
</p>
374 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>d[
<span class=
"s6">\freq
</span>] = [
200,
101,
1102];
</p>
375 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
376 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>