I have a large number of objects. Each object has a unique GUID. I need map objects by this GUID. I use now System.Collections.Hashtable. The problem is adding objects hashset changes its size and causes fragmentation of Large object heap. Also it needs twice as much memory as I have objects. I need to reduce the memory usage.
Features of the data structure I need:
- Add object
- Remove object by ID
- Find object by ID
- Run though all the objects in data structure (foreach)
What is the best datastructure for this purpose? I know there is red-black and AVL trees, but I don't know what tree is better to use. Maybe there is another tree data structure suitable for mapping by unique identifiers or strings? which data structure would work faster?