Closed GoogleCodeExporter closed 9 years ago
Hi xxiaozaichu,
Sorry for the long delay, but I will try to become active again. Life keeps you
scrambling to keep up. :)
Thanks for reporting the issue, but alas its not a bug!
The Identity was introduced because #containsValue() needs to perform an
equality
check. I saw that ConcurrentHashMap's implementation locks the entire
hashtable,
commenting that it was done due to the ABA problem. While I understood the
comment,
I didn't see why it would be a concern. So instead of using an iterator I
introduced
the Identity to conform to the implementation semantics. I plan to weaken it by
using an Iterator<V> and allow for the ABA problem now that I feel more
comfortable
with it.
The Identity is just a pass through for reference checks. The #remove(key,
value)
returns back a boolean on success. However, I need the Node<K, V> instance in
order
to unlink it from the list. So instead I get the instance, perform the value
check,
and try to remove it conditionally. If successful, I can unlink the node.
You are welcome to look at the unit tests to validate that this works
correctly.
Please let me know if you see any flaw in my logic.
Original comment by Ben.Manes@gmail.com
on 20 Oct 2009 at 8:05
Original issue reported on code.google.com by
xxiaozai...@gmail.com
on 15 Sep 2009 at 9:01