I need to find an "efficient" data structure / set of algorithms to do the following things:
I have a list of objects. I need to assign them weights and later on increase or decrease these weights.
For instance:
We have the hashmaps {o1}, {o2}, {o3}
. The {o}
's don't have any particullar structure, just random json.
I am looking for a way of saying: Increase the weight of o1 by 1. Increase the weight of o2 by 1. Increase the weight of o1 by 1. Now give me the results sorted by their weight.
I am using Python. So far I have tried using a normal hashmap to store them, but the problem is that I can't just hash the {o}
's. I thought of hashing the pointer of the {o}
's in memory, but it seems I don't have access to it in Python.
id
function. Or create a wrapper class or create custom dictionary (in python you can inherit fromdict
).