Litte c# help please: dictionary handling, spread of spreads, bin size

dear vvvvolks

i have a little problem with the plugin im working on… if somebody finds a little time, that would be great.

the idea is to have a place to store values, assigned to an ID (an arbitrary string), whereas the values should have a binsize.

now, to do that, i created a dictionnary, with a spread of values assigned to the key (see code)
but there goes something wrong, the incoming values are assigned to all entries in the dictionnary although they should be only assigned the ones i ask for by an if-conditional…

please see the attached patch for a more detailed explanation.
tanks

plugin and explaing patch (12.0 kB)

i’m not sure if that’s the solution to your question, but try this:
line 65:

d.Add(FSetID[i](i), FInputValue[i](i).Clone());
// instead of d.Add(FSetID[i](i), FInputValue[i](i));

one entry in your dictionary stores a reference to the ISpread implementation, which is implemented with a double array whose lifetime is as long as that of your node. that array will be reused in next frame (if the slice count doesn’t grow much). since it is reused all your entries in your dictionary will basically point to the same array or ISpread. therefor you need to copy all the data in the ISpread when you decided to store them in a buffer. the extension method Clone() defined on ISpread does exactly that. hope that helps.

That does the job, wonderful. Thanx Elias!