containskey

Java hashmaps without the value?

Let's say I want to put words in a data structure and I want to have constant time lookups to see if the word is in this data structure. All I want to do is to see if the word exists. Would I use a HashMap (containsKey()) for this? HashMaps use key->value pairings, but in my case I don't have a value. Of course I could use null for t...

Custom Class used as key in Dictionary but key not found.

I have a class, show below, which is used as a key in a Dictionary<ValuesAandB, string> I'm having issues when trying to find any key within this dictionary, it never finds it at all. As you can see, I have overridden Equals and GetHashCode. To look for the key I'm using ValuesAandB key = new ValuesAandB(A,B); if (DictionaryName.Contai...

Java TreeMap containsKey invariably returning true?

I'm writing a Java program that's using the TreeMap interface, and I'm having a problem with containsKey. It is returning true even when I give containsKey something that I know for certain is not in the TreeMap. What could be the cause of this? Thanks so much in advance. -- Edit: I am writing a program that counts the occurrences o...

Dictionary is returning false on ContainsKey after item is added

I have a dictionary declared as follows IDictionary<string, object> _objectIds = new Dictionary<string, object>(); I was experiencing some problems with it and it discovered that the instance returned false as a result of ContainsKey method and from the watch window I was sure that the item was there. So I created helper method priva...