I have b buckets 0....b-1 and m apples 0....m-1. In the beginning all apples are placed in bucket 0.
Then running some analysis causes the apples to be moved among the buckets. I have already implemented this by having a 2D list (as buckets) in which apple ids are removed and appended whenever they need to be moved between buckets. This is, however, very inefficient for my analysis as these movements are in the order of millions or billions. So, I was wondering if there is any better solution out there to implement such a structure?
By the way, the title was chosen as this is very similar to the partitions of a set problem in which no member can be placed in more than 1 subset. Here is also an example with 4 apples and 3 buckets to make it more clear:
time 0:
a=[[0,1,2,3],[],[]]
time 1: (say apple 3 needs to be moved to bucket 2)
a=[[0,1,2],[],[3]]