lundi 8 mai 2017

Observe list and proceed on filter match

This is kind of a question I would put into the category "Computer Science 500" on the Jeopardy wall. Imagine you would have two lists, you fill up with double values periodically (i.e.: each 200ms). Each time a new value is added, you calculate its sum. If a predefined limit is reached (max: 20 items for example), while list A has 18 items added, and list B 20, you want to build the sum of each list and compare its two values. Which list has reached the highest sum? Now, imagine the lists to be used in a ring type memory where the oldest entry gets replace by the newest double value. From the time, the maximum limit has been reached, each new value causes a function call to build the sum. Now to my computer science question/programmatic approach to be used: Which is the best design to handle this fast-filling list correctly and most effectively? The function may take 2s (if it is more complicated), and I am mostly interested to get the updated sum of the current double value data set. IMHO, i need to take a "snapshot" of the current list, (with ToList), and calculate its sum, but in the meantime new values have already been added.

I hope you could get an impression on my stream of consciousness regarding the mentioned issue and may help with some ideas ready to make the lightbulb flash above my head.

Thanks for listening.

Aucun commentaire:

Enregistrer un commentaire