Document HashSet::erase() behavior
Document the case where erasing can result in elements being visited
multiple times during iteration.
Bug: 112754759
Test: make
Change-Id: Ia80cdc20e40311ae20673ce844e662ced43144a0
diff --git a/libartbase/base/hash_set.h b/libartbase/base/hash_set.h
index 2b1a5eb..42aa46f 100644
--- a/libartbase/base/hash_set.h
+++ b/libartbase/base/hash_set.h
@@ -359,6 +359,9 @@
// and set the empty slot to be the location we just moved from.
// Relies on maintaining the invariant that there's no empty slots from the 'ideal' index of an
// element to its actual location/index.
+ // Note that since erase shuffles back elements, it may result in the same element being visited
+ // twice during HashSet iteration. This happens when an element already visited during iteration
+ // gets shuffled to the end of the bucket array.
iterator erase(iterator it) {
// empty_index is the index that will become empty.
size_t empty_index = it.index_;