TIntIntHashMap getNoEntryValue() == 0
Issue #37
resolved
Hi,
The following code
TIntIntHashMap map = new TIntIntHashMap(); map.put(10, 0); System.out.println(map.get(10) == map.getNoEntryValue());
prints 'true'.
Javadocs say, NoEntryValue "can be changed during construction of the collection" and it looks like it should be changed, though it is not.
Is it a bug or a feature?
Comments (7)
-
-
- changed milestone to Next Minor Release
-
assigned issue to
- marked as trivial
Yes, the no entry value can be set during construction. I'm fine with that wording change if it is less confusing.
Comparing a return value is not a great way to see if an entry was contained in the map. Using contains() would be better. Ideally the no entry value would be set to a value your map would never contain (but don't use NaN for floats/doubles!) and then equals comparisons would work. This is dependent on your data set though.
-
- changed status to resolved
Merged in 9394c91
-
I actually changed the word to "configured".
-
- changed milestone to 3.0.5.b1
-
- changed milestone to 3.0.5.m1
-
- changed milestone to 3.1
- Log in to comment
TIntIntHashMap has a constructor
TIntIntHashMap( int initialCapacity, float loadFactor, int noEntryKey, int noEntryValue )
So the only bug is perhaps in the documentation that should say "it can be set during construction" instead of "it can be changed during construction". No major bug, but it could be worth removing this possible source of misunderstanding.