Am I understanding it correctly like this:
If you have structure like this
objects = [1: a, 2: c, 3: x, 4: c, 5:c, 6: a, 7: d]
Your algorithm loops over each element, finds
1:a and searches for all a (6 in this case).
Delete 1 and 6 and send a message to some process?
And then repeat this for the remaining entries? Starting with
Is this correct?
If it’s correct, then can’t you sort the objects by the items first and then do the other actions on them, so sorted like: `a: 1, 6 - c: 2, 4, 5 - x: 3 - d: 7]?
This brings the logarithmic complexity down from an O(n2) to an O(n log n) operation and should be much faster