Forums > MaxMSP

Set of symbols

February 27, 2008 | 3:45 pm

Hello,

I’d like to maintain a unique set of symbols or ints and insert/remove them from a list. It would work like Zl Reg or bag, except that I could use symbols.

So if the contents of the list are:
Foo Bar Baz

I send the message:
remove Baz

and the list now sends out:
Foo Bar.

It should support having nothing in the set, so that when it’s empty you can still get a bang to know it’s empty.

Basically like the data structure "set" in C++

I’ve searched around… Lobjects, etc, and I see nothing like this at all. Seems like a very simple requirement.

Thanks!
- Glot


February 27, 2008 | 4:10 pm

It should work exactly like Peter Elsea’s Lbag, except with support for symbols. Lbag has the proper right side outlet for bang if the list is empty.

- Glot


February 27, 2008 | 8:19 pm

coll ?

On 27 Feb, 2008, at 4:45 PM, Glot wrote:

>
> Hello,
>
> I’d like to maintain a unique set of symbols or ints and insert/
> remove them from a list. It would work like Zl Reg or bag, except
> that I could use symbols.
>
> So if the contents of the list are:
> Foo Bar Baz
>
> I send the message:
> remove Baz
>
> and the list now sends out:
> Foo Bar.
>
> It should support having nothing in the set, so that when it’s
> empty you can still get a bang to know it’s empty.
>
> Basically like the data structure "set" in C++
>
> I’ve searched around… Lobjects, etc, and I see nothing like this
> at all. Seems like a very simple requirement.
>
> Thanks!
> – Glot


February 27, 2008 | 8:23 pm

On Feb 27, 2008, at 7:45 AM, Glot wrote:
> I’d like to maintain a unique set of symbols or ints and insert/
> remove them from a list. It would work like Zl Reg or bag, except
> that I could use symbols.

coll can be your friend here, with a little work:
max v2;
#N vpatcher 171 204 715 737;
#P origin -16 -1;
#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P comment 334 29 172 196617 symbols sent here remove from list ,
toggle in switches meaning of left inlet , like Lbag;
#P window linecount 1;
#P hidden newex 237 93 48 196617 loadbang;
#P message 289 115 14 196617 2;
#P message 304 115 14 196617 1;
#P newex 289 143 38 196617 gate 2;
#P newex 289 92 41 196617 sel 0 1;
#P comment 82 3 73 196617 By Chris Muir;
#P comment 249 35 81 196617 Remove Item(s);
#P message 301 429 14 196617 0;
#P comment 205 496 44 196617 List out;
#P comment 331 496 62 196617 Empty Bang;
#P newex 314 453 29 196617 gate;
#N comlet Number of items;
#P outlet 419 495 15 0;
#P button 287 429 15 0;
#P newex 188 401 36 196617 zl reg;
#P newex 233 70 122 196617 route bang list int float;
#N comlet Remove Item(s) list , sym;
#P inlet 233 35 15 0;
#N comlet List out;
#P outlet 188 494 15 0;
#P message 145 226 31 196617 clear;
#N comlet Add Item(s) list , sym , bang;
#P inlet 9 35 15 0;
#P newex 9 64 181 196617 route bang list int float clear;
#P newex 284 368 40 196617 t b b 1;
#N comlet Empty Bang;
#P outlet 314 494 15 0;
#P newex 345 92 25 196617 iter;
#P button 326 477 15 0;
#P newex 345 226 75 196617 prepend delete;
#P newex 9 226 104 196617 t dump length zlclear;
#P newex 419 256 30 196617 grab;
#P newex 214 338 46 196617 zl group;
#P newex 214 313 69 196617 route symbol;
#P newex 179 86 25 196617 iter;
#P newex 179 203 46 196617 pack s s;
#P newex 179 184 46 196617 t s s;
#P newex 179 226 72 196617 prepend store;
#N coll ;
#P newobj 179 289 116 196617 coll;
#P comment 436 496 84 196617 Number of items;
#P comment 25 35 63 196617 Add Item(s);
#P window setfont "Sans Serif" 18.;
#P comment 1 3 80 196626 SymBag;
#P window setfont "Sans Serif" 9.;
#P hidden comment 0 505 60 196617 bottom left;
#P comment 82 16 250 196617 More or less like Lbag , but… you
know… for symbols;
#P window linecount 2;
#P comment 20 91 108 196617 "clear" is a reserved symbol;
#P connect 21 0 20 0;
#P connect 20 0 14 0;
#P connect 20 4 22 0;
#P connect 20 5 10 0;
#P connect 36 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 7 0;
#P fasten 14 0 6 0 14 264 184 264;
#P lcolor 15;
#P fasten 13 1 6 0 444 278 184 278;
#P lcolor 15;
#P connect 22 0 6 0;
#P lcolor 15;
#P connect 15 0 6 0;
#P lcolor 15;
#P connect 7 0 6 0;
#P lcolor 15;
#P fasten 14 2 26 0 108 393 193 393;
#P fasten 19 1 26 0 304 394 193 394;
#P connect 26 0 23 0;
#P connect 6 1 11 0;
#P connect 11 0 12 0;
#P connect 12 0 26 1;
#P connect 8 1 9 1;
#P connect 24 0 25 0;
#P fasten 13 0 12 1 424 334 255 334;
#P lcolor 12;
#P connect 6 3 19 0;
#P connect 26 0 27 0;
#P connect 25 2 35 0;
#P hidden connect 39 0 38 0;
#P connect 35 0 38 0;
#P connect 37 0 36 0;
#P connect 38 0 36 0;
#P connect 27 0 32 0;
#P connect 35 1 37 0;
#P connect 19 2 29 0;
#P connect 32 0 29 0;
#P connect 29 0 18 0;
#P connect 10 0 36 1;
#P connect 29 0 16 0;
#P fasten 19 0 29 1 289 390 338 390;
#P connect 25 4 17 0;
#P connect 36 1 15 0;
#P connect 17 0 15 0;
#P fasten 14 1 13 0 61 251 424 251;
#P lcolor 12;
#P connect 13 0 28 0;
#P lcolor 12;
#P pop;

Chris Muir
cbm@well.com


February 27, 2008 | 10:05 pm

Thanks Chris, excellent.

Will the use of iter cause the results to happen in another interrupt– or will everything complete in exactly one message event?

- Glot


February 27, 2008 | 10:05 pm

Hi Glot,
Since you mention "set" and C++, are you a programmer? Whenever I need a data structure that Max doesn’t support out-of-the-box I whip something up in a Java external. For object-oriented & data structure stuff this is a lot easier than patching IMO. Then you are in a good position to add all sorts of functionality later that would be difficult in a patch.

It would be easy to make a Max external wrap one of Java’s Set classes (like http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashSet.html) to do everything you need. If you are interested in going this route, I could post a Set external later. With source code so you can customize it if needed. Let me know…


Viewing 6 posts - 1 through 6 (of 6 total)