supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / Collections / Pair.html
blob6c905227b71fe197b1e20fc0c901e35d4500afe8
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
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: 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: 13.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12; min-height: 12.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
17 span.s1 {font: 18.0px Helvetica}
18 span.s2 {color: #002fe0}
19 span.s3 {color: #0000ff}
20 span.s4 {text-decoration: underline ; color: #002fe0}
21 span.s5 {text-decoration: underline ; color: #0039da}
22 span.s6 {color: #001bb9}
23 span.s7 {color: #ad140d}
24 span.Apple-tab-span {white-space:pre}
25 </style>
26 </head>
27 <body>
28 <p class="p1"><span class="s1"><b>Pair</b></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><b>LISP-like two element cells</b></p>
29 <p class="p2"><br></p>
30 <p class="p1"><b>Inherits from: </b><a href="../Core/Object.html"><span class="s2"><b>Object</b></span></a><span class="s2"><b> : </b><a href="Collection.html"><span class="s3"><b>Collection</b></span></a></span></p>
31 <p class="p2"><br></p>
32 <p class="p1">(implementation incomplete. See<b> </b><a href="../Language/J_concepts_in_SC.html"><span class="s4">J Concepts In SC</span></a><span class="s5"> </span>for similar functionality)</p>
33 <p class="p2"><br></p>
34 <p class="p3"><b>Class Methods</b></p>
35 <p class="p2"><br></p>
36 <p class="p2"><br></p>
37 <p class="p1"><b>*new(linkDown, linkAcross) <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>return new instance</p>
38 <p class="p2"><br></p>
39 <p class="p1"><b>*newFrom(collection)</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>convert collection (e.g. arrays of arrays) to pairs.</p>
40 <p class="p2"><br></p>
41 <p class="p2"><br></p>
42 <p class="p2"><br></p>
43 <p class="p3"><b>Instance Methods</b></p>
44 <p class="p2"><br></p>
45 <p class="p1">Most methods are inherited from the superclasses.</p>
46 <p class="p2"><br></p>
47 <p class="p1"><b>size</b></p>
48 <p class="p2"><br></p>
49 <p class="p1">return the size when linking across</p>
50 <p class="p2"><br></p>
51 <p class="p1"><b>depth</b></p>
52 <p class="p2"><br></p>
53 <p class="p1">return the size when linking down</p>
54 <p class="p2"><br></p>
55 <p class="p1"><b>do(function)</b></p>
56 <p class="p2"><br></p>
57 <p class="p1">iterate over the two elements</p>
58 <p class="p2"><br></p>
59 <p class="p1"><b>traverse(function)</b></p>
60 <p class="p2"><br></p>
61 <p class="p1">same like: depthFirstPreOrderTraversal</p>
62 <p class="p2"><br></p>
63 <p class="p1"><b>depthFirstPreOrderTraversal(function)</b></p>
64 <p class="p2"><br></p>
65 <p class="p1">traverse the data structure first link down, then across (see example).</p>
66 <p class="p2"><br></p>
67 <p class="p1"><b>depthFirstPostOrderTraversal(function)</b></p>
68 <p class="p2"><br></p>
69 <p class="p1">traverse the data structure from bottom up (see example)</p>
70 <p class="p2"><br></p>
71 <p class="p4"><br></p>
72 <p class="p5">// example</p>
73 <p class="p6"><br></p>
74 <p class="p7">a = <span class="s6">Pair</span>(<span class="s6">Pair</span>(<span class="s6">Pair</span>(1, 2), 4), <span class="s6">Pair</span>(5, 6));</p>
75 <p class="p6"><br></p>
76 <p class="p6"><br></p>
77 <p class="p7">a.size;</p>
78 <p class="p7">a.depth;</p>
79 <p class="p7">a.do { <span class="s6">|x|</span> x.postln };</p>
80 <p class="p7">a.traverse { <span class="s6">|x|</span> x.postln };</p>
81 <p class="p7">a.depthFirstPreOrderTraversal { <span class="s6">|x|</span> x.postln };</p>
82 <p class="p7">a.depthFirstPostOrderTraversal { <span class="s6">|x|</span> x.postln };</p>
83 <p class="p6"><br></p>
84 <p class="p6"><br></p>
85 <p class="p5">// alternative instantiations:</p>
86 <p class="p6"><br></p>
87 <p class="p7"><span class="s6">Pair</span>.newFrom([1, [2, [[4, 5], 6]]]);</p>
88 <p class="p6"><br></p>
89 <p class="p7">[1, [2, [[4, 5], 6]]].as(<span class="s6">Pair</span>); <span class="s7">// equivalent.</span></p>
90 <p class="p6"><br></p>
91 <p class="p6"><br></p>
92 <p class="p6"><br></p>
93 <p class="p6"><br></p>
94 </body>
95 </html>