Is it possible to retrieve the index of a key-value pair within a hashtable?
I find odd it's not possible, or is it by design?
I got lost in msdn hashtable description, I am unfortunatly not very good at extracting the info I need from the msdn help just yet...
Is there a better alternative. I need to access a class given a string reference and I need them organize so that I can access them in order, getting the next class.
The 'index' into a hash table is the key (by definition) since it's an associative container. The concept of an integer index like an array may or may not make sense depending on the hash table implementation. It only makes sense if the hash table uses open addressing but not if it uses seperate chaining (which is more common in my experience).
you save the keys into an array, save the values in another array, and then find the index of your key and get the value from the second array of that index.
of course, this is ugly… but that works for my needs.