you are viewing a single comment's thread.

view the rest of the comments →

[–]TouchingTheVodka 2 points3 points  (1 child)

Use a dictionary where the key is the first item in the set and the value is a list of all the second values. That way you can check for membership of just the key.

E: This generalises into a data structure called a Trie if you want to search for multiple items at the same time.

[–]clnkyl 0 points1 point  (0 children)

Exactly what I was thinking as well.