Add a comment to the get_hash method

This commit is contained in:
Giles Bathgate 2022-04-04 17:38:41 +01:00
parent 4f9bb66292
commit 104aca6295
1 changed files with 10 additions and 0 deletions

View File

@ -65,6 +65,16 @@ class ID_support_handler<SNC_indexed_items, Decorator> {
hash.reserve(n); hash.reserve(n);
} }
// The method get_hash implements a
// two-pass union find algorithm
// __ __ _______
// / \ / \ / _____\
// _|__|__|__|_ _/__/__/__|_
// | | v | v | | | | | v |
// | O O O O | => | O O O O |
// |____|__^____| |____________|
// | | root
// \_/
int get_hash(int i) { int get_hash(int i) {
int root(i); int root(i);
while(hash[root] != root) while(hash[root] != root)