aboutsummaryrefslogtreecommitdiff
path: root/PDContainer/help/h_deque-help.pd
blob: c28052e272d2e040c89f48819dee9a0e6dc1a995 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
#N canvas 344 22 799 883 10;
#X obj 147 379 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 498 23 cnv 15 204 120 empty empty empty 20 12 0 14 -66577 -66577
0;
#X obj 500 25 cnv 15 200 116 empty empty ReadMe: 65 15 0 14 -262131
-143491 0;
#N canvas 674 0 511 843 General_Concept 0;
#X text 37 165 This library was made for algorithmic composition and
of course for all other algorithms. I came into troubles with making
bigger musical structures in PD with send-receive pairs \, arrays \,
etc. So I tried to make it possible \, to have access to some storage
in a whole patch.;
#X text 131 131 ::: GOAL OF THE LIBRARY :::;
#X text 39 428 For communication I use namespaces. Every Container
with the same namespace (and the same container type) has access to
the same data. So you can modify and get this data everywhere in the
patch. For local namespaces use names with \$0.;
#X text 140 266 ::: DATASTRUCTURES :::;
#X text 156 397 ::: NAMESPACES :::;
#X obj 33 24 cnv 15 404 54 empty empty empty 22 25 0 18 -1 -66577 0
;
#X obj 35 26 cnv 15 400 50 empty empty PDContainer 22 25 0 18 -228992
-66577 0;
#N canvas 434 247 671 362 namespace_example 0;
#X obj 43 176 h_stack hallawum;
#X msg 43 151 push some data;
#X text 34 25 ::: NAMESPACE EXAMPLE :::;
#X text 166 150 <- add the list "some data" to the stack;
#X text 187 167 (namespace "hallawum");
#X obj 41 254 h_stack hallawum;
#X msg 41 231 top;
#X text 76 231 <- get the data (same namespace);
#X msg 341 235 top;
#X obj 341 258 h_stack kaletom;
#X obj 341 281 print BBB;
#X obj 41 277 print AAA;
#X text 376 235 <- get the data (different namespace);
#X text 475 271 not possible !!!;
#X text 35 65 In different namespaces you have access to different
data. Here with the datastructure "stack". The two objects with the
same namespace (here "hallawum") are sharing their data!;
#X connect 1 0 0 0;
#X connect 5 0 11 0;
#X connect 6 0 5 0;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X restore 39 503 pd namespace_example;
#X text 161 554 ::: DATATYPES :::;
#X text 38 296 As storage datastructures I implemented the C++ STL
(Standard Template Library) Containers in PD. Currently following datastructures
are available (prefixed with h_): h_map \, h_multimap \, h_set \, h_multiset
\, h_vector \, h_list \, h_deque \, h_queue \, h_priority_queue and
h_stack.;
#N canvas 438 21 583 739 map_example 0;
#X obj 45 297 h_map \$0-data;
#X msg 45 256 add data1;
#X msg 131 273 1 4 3 5 6;
#X obj 45 220 t b b;
#X obj 45 194 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 321 303 h_map \$0-data;
#X obj 321 226 t b b;
#X obj 321 200 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X msg 321 262 add data2;
#X msg 407 279 6 4 5 1 2;
#X obj 118 402 h_map \$0-data;
#X msg 118 376 print;
#X text 170 375 <- see whats in the container;
#X obj 118 556 h_map \$0-data;
#X msg 118 485 get data1;
#X msg 142 519 get data2;
#X obj 118 578 print AAA;
#X text 202 485 <- get data1;
#X text 229 520 <- get data2;
#X text 345 199 <- add to key data2 a list;
#X text 69 193 <- add to key data1 a list;
#X text 32 32 ::: MAP_EXAMPLE :::;
#X text 34 72 With the datastructure "map" it's for example possible
to make send-receive pairs \, you don't have to update the send-receive
pairs all the time (like [value]) \, you can use send-receive "namespaces"
\, ...;
#X text 111 659 ( If you use lists as key you can also make a multidimensional
matrix ... );
#X connect 1 0 0 0;
#X connect 2 0 0 1;
#X connect 3 0 1 0;
#X connect 3 1 2 0;
#X connect 4 0 3 0;
#X connect 6 0 8 0;
#X connect 6 1 9 0;
#X connect 7 0 6 0;
#X connect 8 0 5 0;
#X connect 9 0 5 1;
#X connect 11 0 10 0;
#X connect 13 0 16 0;
#X connect 14 0 13 0;
#X connect 15 0 13 0;
#X restore 41 615 pd map_example;
#X text 273 34 general concept of;
#X text 274 52 PDContainer;
#X text 41 579 In the containers you can save all of the PD build-in
datatypes: lists \, floats \, and symbol.;
#N canvas 215 140 716 600 save_load_example 0;
#X text 27 23 ::: SAVE/LOAD EXAMPLE :::;
#X msg 68 229 pushback one word;
#X msg 90 260 pushback an other word;
#X msg 114 290 pushback something else;
#X obj 68 198 t b b b;
#X obj 68 168 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 68 324 h_list \$0-local;
#X text 93 168 <- add these three lists to h_list;
#X obj 333 321 h_list \$0-local;
#X msg 358 285 print;
#X obj 140 477 h_set blablu;
#X msg 140 413 read example.dat;
#X text 274 413 <- read the same data now into a h_set;
#X text 26 67 You can save and load data from and to disk. So you can
also exchange data through different datastructures with the same data-format
(here from a h_list to a h_set).;
#X msg 178 441 print;
#X msg 333 207 saveXML example.xml;
#X text 457 238 <- save data as file;
#X msg 333 238 save example.dat;
#X text 477 208 <- save data as XML file;
#X msg 140 378 readXML example.xml;
#X text 283 379 <- read the same XML data now into a h_set;
#X text 22 529 Please use the XML fileformat if possible \, because
it's easier to edit in an external editor and the XML parser is much
more stable !;
#X connect 1 0 6 0;
#X connect 2 0 6 0;
#X connect 3 0 6 0;
#X connect 4 0 1 0;
#X connect 4 1 2 0;
#X connect 4 2 3 0;
#X connect 5 0 4 0;
#X connect 9 0 8 0;
#X connect 11 0 10 0;
#X connect 14 0 10 0;
#X connect 15 0 8 0;
#X connect 17 0 8 0;
#X connect 19 0 10 0;
#X restore 40 797 pd save_load_example;
#X text 41 696 All the data of all containers can be saved to disk.
So you can also manually edit the file with an editor (which is sometimes
much faster) and then load it in PD into a container. You can also
load data from other containers. Please use the XML fileformat if possible
\, because it's easier to edit in an external editor and the XML parser
is much more stable.;
#X text 164 671 ::: SAVE/LOAD :::;
#X restore 534 61 pd General_Concept;
#X obj 33 24 cnv 15 404 54 empty empty empty 22 25 0 18 -1 -66577 0
;
#X obj 35 26 cnv 15 400 50 empty empty PDContainer 22 25 0 18 -228992
-66577 0;
#X text 295 36 help file of;
#X text 36 98 init arg: namespace;
#X msg 480 293 print;
#X msg 480 379 clear;
#X msg 480 664 help;
#X obj 559 715 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X msg 480 234 getnamespace;
#X msg 480 417 clearall;
#X obj 480 763 print BBB;
#X obj 68 380 print AAA;
#X text 591 259 <- change namespace;
#X msg 480 258 namespace grix;
#X text 527 294 <- print all the data of the;
#X text 546 309 current namespace;
#X text 528 379 <- clear all the data of the;
#X text 549 394 current namespace;
#X text 548 419 <- clear all the data in all;
#X text 569 434 same containers (maybe;
#X text 571 449 you shouldn't use this);
#X text 580 236 <- get current namespace;
#X text 512 193 general operations:;
#X msg 294 341 list damm 4345 it;
#X floatatom 294 247 5 0 0 0 - - -;
#X symbolatom 294 265 10 0 0 0 - - -;
#X msg 294 317 hacka 45;
#X msg 294 294 3 4 krschi;
#X text 304 216 value:;
#N canvas 205 0 993 742 Container_Explanation 0;
#X obj 14 13 cnv 15 404 54 empty empty empty 22 25 0 18 -1 -66577 0
;
#X obj 16 15 cnv 15 400 50 empty empty PDContainer 22 25 0 18 -228992
-66577 0;
#X text 254 23 general explation of;
#X text 254 40 the datastructures;
#X text 23 655 A vector is a sequence that supports access to all elements
via index (like an array) and fast insertion and removal of elements
at the end. The number of elements in a vector may vary dynamically.
;
#X obj 189 627 h_vector;
#X text 500 654 Fast insertion and removal anywhere \, all the other
elements move up. But a list provides only sequential access (not via
index !). A list is a doubly linked list.;
#X obj 680 628 h_list;
#X obj 189 773 h_deque;
#X text 498 801 A queue is a "first in first out" (FIFO) data structure.
That is \, elements are added to the back of the queue (push) and may
be removed from the front (pop).;
#X obj 679 774 h_queue;
#X text 22 951 A priority queue is also a "first in first out" (FIFO)
data structure \, but you can give the elements a priority. So the
elements with a higher priority are automatically inserted before all
other elements with a lower priority.;
#X obj 154 924 h_priority_queue;
#X text 20 800 A deque (double ended queue \, pronounced "deck") is
very much like a vector: like vector \, it is a sequence that supports
access to all elements via index. The main way in which deque differs
from vector is that fast insertion and removal of elements is possible
at the beginning _and_ the end.;
#X text 22 232 Maps represent a mapping from one type (the key type)
to another type (the value type). You can associate a value with a
key \, or find the value associated with a key \, very efficiently.
Map is a Sorted Associative Container and it is also a Unique Associative
Container \, meaning that no two elements have the same key. (see Multimap
for more elements with the same key);
#X obj 188 203 h_map;
#X text 492 231 Multimaps are just like maps except that a key can
be associated with several values. Multimap is a Sorted Associative
Container and also a Multiple Associative Container \, meaning that
there is no limit on the number of elements with the same key. (see
also Map);
#X obj 643 201 h_multimap;
#X text 24 419 Sets allow you to add and delete elements. Afterwards
you can look if an element is set. Set is a Sorted Associative Container
and a Unique Associative Container \, meaning that no two elements
are the same. (see Multiset to have several copies of the same element)
;
#X obj 187 392 h_set;
#X text 493 419 Multisets are just like sets \, except that you can
have several copies of the same element. Multiset is a Sorted Associative
Container and a Multiple Associative Container \, meaning that two
or more elements may be identical. (see also Set);
#X obj 642 391 h_multiset;
#X text 339 167 :::: ASSOCIATIVE CONTAINERS ::::;
#X text 393 592 :::: SEQUENCES ::::;
#X text 289 1099 (look for help at all the objects for more information)
;
#X text 35 87 PDContainer contains the following datastructures:;
#X text 399 86 map \, nultimap \, set \, multiset \, vector \, list
\, deque \, queue \, stack \, priority queue;
#X obj 679 916 h_stack;
#X text 495 950 Stack is a "last in first out" (LIFO) data structure:
the element at the top of a stack is the one that was most recently
added (push). Top outputs the elements from the top without removing
it \, pop outputs and removes it.;
#X restore 516 89 pd Container_Explanation;
#X msg 480 601 resize \$1;
#X msg 480 635 getsize;
#X floatatom 488 573 5 0 0 0 - - -;
#X floatatom 519 734 5 0 0 0 - - -;
#X text 545 634 <- get the size (at 2nd;
#X text 567 648 outlet);
#X msg 68 290 get \$1;
#X floatatom 74 269 5 0 0 0 - - -;
#X floatatom 74 226 5 0 0 0 - - -;
#X msg 68 247 set \$1;
#X msg 71 706 insert \$1;
#X floatatom 80 687 5 0 0 0 - - -;
#X floatatom 79 731 5 0 0 0 - - -;
#X msg 70 752 remove \$1;
#X text 124 246 <- changes the value;
#X text 145 260 at that index;
#X text 142 304 at that index;
#X text 121 290 <- get the value;
#X text 167 379 <- bang if not found;
#X msg 69 519 popback;
#X floatatom 79 429 5 0 0 0 - - -;
#X msg 69 449 pushback \$1;
#X text 209 456 <- inserts the data at the;
#X msg 178 776 some data;
#X text 152 679 remove and insert at index:;
#X text 188 716 If you need this very often you;
#X text 188 730 should better use a list or a map;
#X text 188 743 (or something else) !;
#X symbolatom 124 429 10 0 0 0 - - -;
#X text 283 54 ::: h_deque :::;
#X text 37 126 A deque (double ended queue \, pronounced "deck") is
very much like a vector: like vector \, it is a sequence that supports
access to all elements via index. The main way in which deque differs
from vector is that fast insertion and removal of elements is possible
at the beginning _and_ the end.;
#X obj 68 358 h_deque havi;
#X obj 70 776 h_deque havi;
#X obj 69 619 h_deque havi;
#X obj 480 691 h_deque havi;
#X text 560 735 <- size of deque;
#X text 556 602 <- resizes the deque;
#X text 187 702 Thats not very fast with a deque!;
#X msg 69 489 pushfront \$1;
#X floatatom 79 470 5 0 0 0 - - -;
#X symbolatom 122 470 10 0 0 0 - - -;
#X msg 69 542 popfront;
#X msg 69 572 back;
#X msg 69 594 front;
#X text 229 471 front/back of the deque;
#X text 208 485 (so the size will increase);
#X text 143 521 <- removes the element from the;
#X text 143 539 back/front (so the size will decrease);
#X text 124 571 <- gives out the element from the;
#X text 146 586 back/front;
#X obj 69 641 print CCC;
#N canvas 254 0 927 786 Fileformats 0;
#X obj 38 27 cnv 15 404 54 empty empty empty 22 25 0 18 -1 -66577 0
;
#X obj 40 29 cnv 15 400 50 empty empty PDContainer 22 25 0 18 -228992
-66577 0;
#X text 259 56 PDContainer;
#X text 257 38 different fileformats of;
#X text 472 116 Please use the XML fileformat if possible \, because
it's easier to edit in an external editor and the XML parser is much
more stable!;
#X text 40 582 s go;
#X text 40 569 f 2 s wow f 2;
#X text 40 599 f 23;
#X text 38 634 (f=float \, s=symbol);
#X text 37 171 a) single elements: are the containers h_vector \, h_list
\, h_deque \, h_set \, h_multiset;
#X text 471 172 b) key-value pairs: are the containers h_map and h_multimap
;
#X text 469 276 2.element: symbol go;
#X text 476 698 f 2 s wow - f 2;
#X text 476 712 s go - s not f 34;
#X text 476 729 f 23 - s op;
#X text 488 244 key: list 2 wow;
#X text 470 229 1.element:;
#X text 488 258 value: float 2;
#X text 490 291 key: symbol go;
#X text 490 305 value: list symbol not float 34;
#X text 39 243 1.element: list 2 wow 2;
#X text 39 257 2.element: symbol go;
#X text 38 272 3.element: float 23;
#X text 37 223 a) example1:;
#X text 470 212 b) example2:;
#X text 37 312 a) example1 \, XML:;
#X text 37 339 <?xml version="1.0" encoding="ISO-8859-1" ?>;
#X text 37 353 <PDContainer type="h_list">;
#X text 54 366 <element>;
#X text 70 379 <f> 2 </f>;
#X text 70 405 <f> 2 </f>;
#X text 56 418 </element>;
#X text 70 391 <s> wow </s>;
#X text 56 431 <element>;
#X text 57 455 </element>;
#X text 72 443 <s> go </s>;
#X text 56 468 <element>;
#X text 57 492 </element>;
#X text 72 480 <f> 23 </f>;
#X text 41 506 </PDContainer>;
#X text 41 542 a) example1 \, textfile:;
#X text 39 115 You can save the data of the containers to XML files
and normal textfiles (see General_Concept).;
#X text 469 375 <?xml version="1.0" encoding="ISO-8859-1" ?>;
#X text 469 389 <PDContainer type="h_list">;
#X text 486 402 <element>;
#X text 519 430 <f> 2 </f>;
#X text 520 482 <f> 2 </f>;
#X text 488 506 </element>;
#X text 519 442 <s> wow </s>;
#X text 475 634 </PDContainer>;
#X text 469 348 b) example2 \, XML:;
#X text 503 415 <key>;
#X text 504 456 </key>;
#X text 503 468 <value>;
#X text 504 494 </value>;
#X text 487 519 <element>;
#X text 489 621 </element>;
#X text 504 532 <key>;
#X text 505 559 </key>;
#X text 504 571 <value>;
#X text 505 609 </value>;
#X text 520 545 <s> go </s>;
#X text 521 584 <s> not </s>;
#X text 521 597 <f> 34 </f>;
#X text 476 668 b) example2 \, textfile:;
#X restore 548 115 pd Fileformats;
#N canvas 174 18 646 402 read_save_possibilities 0;
#X obj 44 336 outlet;
#X msg 44 208 save data.dat;
#X msg 44 244 read data.dat;
#X msg 44 288 readat data.dat 0;
#X text 149 208 <- save all the data of the current namespace as textfile
;
#X text 143 244 <- read this textfile to the current namespace and
insert it at the back (so the size will increase);
#X text 177 287 <- read the textfile and insert it at the given index
(so the size won't increase !);
#X text 166 94 <- read this XML-file to the current namespace and insert
it at the back (so the size will increase);
#X text 169 61 <- save all the data of the current namespace as XML-file
;
#X text 196 139 <- read the XML-file and insert it at the given index
(so the size won't increase !);
#X msg 44 61 saveXML data.xml;
#X msg 44 93 readXML data.xml;
#X msg 44 139 readatXML data.xml 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
#X connect 10 0 0 0;
#X connect 11 0 0 0;
#X connect 12 0 0 0;
#X restore 480 491 pd read_save_possibilities;
#X text 520 515 different possiblities to read;
#X text 520 529 and write from and to files;
#X text 519 544 (XML and textfiles);
#X text 216 844 htttp://grh.mur.at/software/pdcontainer.html;
#X text 180 827 =%)!(%= PDContainer \, by Georg Holzmann <grh@mur.at>
\, 2005;
#X msg 480 334 getall;
#X text 535 335 <- dumps out all data sequentially;
#X text 556 349 at the first outlet;
#X connect 8 0 68 0;
#X connect 9 0 68 0;
#X connect 10 0 68 0;
#X connect 12 0 68 0;
#X connect 13 0 68 0;
#X connect 17 0 68 0;
#X connect 27 0 65 1;
#X connect 28 0 65 1;
#X connect 29 0 65 1;
#X connect 30 0 65 1;
#X connect 31 0 65 1;
#X connect 34 0 68 0;
#X connect 35 0 68 0;
#X connect 36 0 34 0;
#X connect 40 0 65 0;
#X connect 41 0 40 0;
#X connect 42 0 43 0;
#X connect 43 0 65 0;
#X connect 44 0 66 0;
#X connect 45 0 44 0;
#X connect 46 0 47 0;
#X connect 47 0 66 0;
#X connect 53 0 67 0;
#X connect 54 0 55 0;
#X connect 55 0 67 0;
#X connect 57 0 66 1;
#X connect 62 0 55 0;
#X connect 65 0 15 0;
#X connect 65 2 0 0;
#X connect 67 0 84 0;
#X connect 68 0 14 0;
#X connect 68 1 37 0;
#X connect 68 2 11 0;
#X connect 72 0 67 0;
#X connect 73 0 72 0;
#X connect 74 0 72 0;
#X connect 75 0 67 0;
#X connect 76 0 67 0;
#X connect 77 0 67 0;
#X connect 86 0 68 0;
#X connect 92 0 14 0;