insert().second -> true for duplicates, + minor bugs
Status: Beta
Brought to you by:
igor_chalenko
1. Given:
hamt<const char*, int> m;
int k = 1;
const char *p = "fred";
m.insert(pair<const char*, int>(p, k));
The following evaluates to true, but
insert().second should evaluate to
false for duplicate keys:
m.insert(pair<const char*, int>(p, k)).second
Fixed by returning end() instead of
iterator(node, trie) in _insert().
2. operator=(const T &rhs) should always
firstly check for assignment to self to
catch statements like: x = x.
Ie:
if (this == &rhs)
return *this;
...
1. operator==(const T &lhs, const T &rhs)
should check for identity, before checking
for equivalence. Ie
if (&lhs == &rhs) return true;
...
Diff against the attached modified hamt.hpp
to see the changes.
Thanks
Andrew
hamt.hpp