decided to start with vl after the feature freeze :)
so know i tried to fill up a dictionary with two spreads from vvvv. one for the values “float32” and one for the keys “int32”.
This seems to work but i want the dictionary to keep its entries once added and only delete them when i specifically want them to be deleted. atm the behaviour of the patch is that when i change the input spreads to a lower spreadcount the dictionary also lower its count. i want it to continue output all the entries once added. wheres my mistake? dictionary.zip (5.3 KB)
Your input needs to be a sequence of float32’s (middle click the ‘Value’ input can configure it to read “Sequence< Float32 >”)
Then you put them all into a loop and add them individually. Note the different inputs of the loop. the diamond is an accumulator with collects the new value at the bottom and returns the collected value for the next loop.
ahhh. i had a sequence type onm the inputs in my first try. but i didnt know about the accumulators. so in the end i had a spread of spread of dictionaries on the outputs… will try out and come back with new questions :)
uk, the weird thing here is that the IOBox at the bottom is typed to Sequence which dictates this type for all Values of the dictionary. so if you simply disconnect that iobox or remove its type annotation (middleclick-> remove the entry in the “Type” field) it will work as expected.
there is no mistake in that sense. the ‘Update’ operation of your vl code is called by vvvv in every frame. so you need to store the dictionary over time to access the same dictionary in the next frame. like a frame delay, but nicer and with a name.
in order to do that you can create a ‘Pad’ (which is an accessor for a property) from the node browser or click Properties ‘+’ in the code explorer in the top left corner:
hm so the when i create the pad MyDict the instance of the directory is created outside the ForEach Loop?
when there are no pads it got created inside the foreach scope therefore it got created and deleted each frame?
also i didnt really get the concept of the accumulator. guest writes: “the diamond is an accumulator with collects the new value at the bottom and returns the collected value for the next loop.”
isnt that what the pad “MyDict” allready does in tonfilms example?
yes[quote=“elektromeier, post:9, topic:14391”]
hm so the when i create the pad MyDict the instance of the directory is created outside the ForEach Loop? when there are no pads it got created inside the foreach scope therefore it got created and deleted each frame?
yes, the key point here is the scope. a pad stores data as long as the node/type lives but the accumulator only during the execution of the loop.
the standard dictionary in VL is immutable, so if it changes in an iteration of the loop you need to have the updated dictionary in the next iteration, that’s what the accumulator does. and when the loop is finished you take the final dictionary from the accumulator and store it back in the pad for the next frame.
As far as adding items to the dictionary as you want to here is am example of how that can work. It was a bit annoying because I found that I had to put the pads in outside of the record. DictionaryCorner.zip (9.2 KB)