Collection: Find value by key, or key by value?

  • Thread starter Thread starter cmay
  • Start date Start date
C

cmay

I have a situation where I need a collection, where I can find the
VALUE (e.g. customer name) by it's key (ID value), AND also find the
ID value by the customer name.

Is there anything that does this?
 
I have a situation where I need a collection, where I can find the
VALUE (e.g. customer name) by it's key (ID value), AND also find the
ID value by the customer name.

Is there anything that does this?

Well, technically you can do this with a plain old dictionary - but,
you would have to do the lookup your self :). So, to do what your
asking I suggest you have a two parallel dictionaries. One keyed by
the id, of course that presents a problem if the name is not unique :)
 
The good old hashtable can do this and is by my knowledge the fastest in
key value pairs ( is verry low level data storage and retrieval , one level
lower and you are at array level )

If you need sorting , querying on value members in the way of structures
that are stored in the value meber then i would advise you to use a
DataTable

HTH

Michel
 
Back
Top