View Full Version : Which collection should I use if...

12-23-2009, 11:28 AM
I need a collection with numeric indices which update when item is removed or added, the items in a collection must be unique, there shouldn't be empty indices, performance and ease of implementation also matter, however, are less important.
So far I tried:
TypedDictionary<MyType, UInt>
- I need to add functionality for updating the indices.
Array<MyType>, List<MyType>
- I need to add functionality to prevent empty indices and repetitive entries.
- Easier to check for repetitions, however, creates a new class per each type of values.
Hash<MyType> isn't really an option since it uses strings for indices. Though IntHash<MyType> could be an option, but it is almost the same as TypedDictionary.

Could be there are more collection types, and I just missed some?
What would you use in such case?

01-03-2010, 06:30 PM
My guess is you are from java background :)


try hash map from the link above.

01-04-2010, 11:37 PM
Ha, nope, if I program any other language it'd be C#, but, I'm rather a beginner in there :)
BTW, I've found yet another article that also clarified it for me:
However, thanks for the link, it was useful reading as well.