I have an associative array of element IDs to counts of each element.
e.g. (in python):
myObject = { 'a': 5, 'b': 3 }
It should support addition and subtraction. For example:
myObject - { 'a': 3 }
Should evaluate to:
{ 'a': 2, 'b': 3 }
For context, this is supporting a costs system. Each element is a resource type, and the quantity is how much of that resource the entity owns. A user would have one of these objects as an inventory of some kind, but then an item might have one of these as its cost. As a result, the user object can simply subtract the item’s cost from their inventory.
I’m just trying to think of a good term for this kind of object.
This collection type is already in Python 2.7 and 3.1. It’s called a Counter.