BagT Class |
Namespace: Kit.Containers
public class Bag<T> : Dictionary<T, int>
The BagT type exposes the following members.
| Name | Description | |
|---|---|---|
| Add(IDictionaryT, Int32) | Adds the amount of items from another dictionary. | |
| Add(KeyValuePairT, Int32) | Adds the amount of items. | |
| Add(BunchT) | Adds the amount of items. | |
| Add(T, Int32) | Adds the amount of items. | |
| AsBunches | Convert the dictionary to a enumerable of Bunches. | |
| Contains(IDictionaryT, Int32) | Returns whether it contains the specified amounts of items. | |
| Contains(KeyValuePairT, Int32) | Returns whether it contains the specified amount of an item. | |
| Contains(BunchT) | Returns whether it contains the specified amount of an item. | |
| Contains(T, Int32) | Returns whether it contains the specified amount of an item. | |
| Remove(IDictionaryT, Int32) | Removes the amount of items from another dictionary. | |
| Remove(KeyValuePairT, Int32) | Removes the amount of items. | |
| Remove(BunchT) | Removes the amount of items. | |
| Remove(T, Int32) | Removes the amount of items. | |
| RemoveAll(IEnumerableT) | Sets the amount of specified items to 0. | |
| RemoveAll(T) | Sets the amount of specified items to 0. | |
| ToBunches | Convert the dictionary to a List of Bunches. |
| Name | Description | |
|---|---|---|
| Added | Event called whenever a new item is added. | |
| Changed | Event called whenever an item's amount is changed. | |
| Removed | Event called whenever an item is removed. |
| Name | Description | |
|---|---|---|
| Addition(BagT, BunchT) | Add an item to the bag. | |
| Addition(BagT, IDictionaryT, Int32) | Add items to the bag. | |
| Addition(BagT, KeyValuePairT, Int32) | Add an item to the bag. | |
| Addition(BagT, T) | Add an item to the bag. | |
| Subtraction(BagT, BunchT) | Remove an item from the bag. | |
| Subtraction(BagT, IDictionaryT, Int32) | Remove items from the bag. | |
| Subtraction(BagT, KeyValuePairT, Int32) | Remove an item from the bag. | |
| Subtraction(BagT, T) | Remove an item from the bag. |
| Name | Description | |
|---|---|---|
| Max |
A function that should return the maximum amount of items of a particular type can be there. The amounts will be capped to this
function's values if specified. Ignored if .
|
Bag<Currency> wallet = new Bag<Currency>(); Bunch<Currency> cost = new Bunch<Currency>(Currency.Diamonds, 10); wallet[Currency.Diamonds] = 50; wallet[Currency.Coins] = 25; wallet -= cost;