0

I am planning to write a C# application that reads from a video game's memory and lists the various active objects in the current level. I have completely mapped out each object's unique identifier, resulting in a large list of String:UInt32 pairs. Since I'm aiming to have this program update object statuses in near real-time, I need a way of being able to cross reference Strings with their respective UInt32s and vice versa.

Normally, I would use a Dictionary map for this task. However, I know that Dictionaries are often purposed to allow dynamic values paired with a key, meaning that you can get the value from a key efficiently, but cannot get the key with a value without iterating through each key until the correct one is found. The data I will be storing will be constant.

Is there a way for me to create a Key:Key structure to allow efficient cross referencing the Strings and UInt16s with their respective counterparts? At the very least, is there a way to search through a dictionary as if the value were a key itself?

Filburt
  • 17,626
  • 12
  • 64
  • 115
w0f
  • 908
  • 9
  • 23
  • what if the key was a hash of the object? – Deblaton Jean-Philippe Aug 21 '15 at 22:21
  • "_The data I will be storing will be constant._" then why not make that constant value the key instead? I'm not clear on what you mean here. – ryanyuyu Aug 21 '15 at 22:22
  • Both the key and the value will be constant. I need a data structure that allows me to look up one or the other, but Dictionaries do not support search via Value – w0f Aug 21 '15 at 22:24
  • use two dictionaries. the second dictionary holds values as key and keys as value from 1st dictionary – M.kazem Akhgary Aug 21 '15 at 22:25
  • there are many answers that solve this problem http://stackoverflow.com/questions/2444033/get-dictionary-key-by-value http://stackoverflow.com/questions/4001908/get-dictionary-key-by-using-the-dictionary-value – IROEGBU Aug 21 '15 at 22:26

0 Answers0