BLI: Return number of roots in disjoint set reduction

This commit is contained in:
Hans Goudey
2024-08-05 13:50:06 -04:00
parent d24b87f94d
commit 85757cb98d
2 changed files with 4 additions and 2 deletions

View File

@@ -141,8 +141,9 @@ class AtomicDisjointSet {
* Get an identifier for each id. This is deterministic and does not depend on the order of
* joins. The ids are ordered by their first occurrence. Consequently, `result[0]` is always zero
* (unless there are no elements).
* \return The total number of unique IDs.
*/
void calc_reduced_ids(MutableSpan<int> result) const;
int calc_reduced_ids(MutableSpan<int> result) const;
/**
* Count the number of disjoint sets.

View File

@@ -31,7 +31,7 @@ static void update_first_occurrence(Map<int, int> &map, const int root, const in
});
}
void AtomicDisjointSet::calc_reduced_ids(MutableSpan<int> result) const
int AtomicDisjointSet::calc_reduced_ids(MutableSpan<int> result) const
{
BLI_assert(result.size() == items_.size());
@@ -88,6 +88,7 @@ void AtomicDisjointSet::calc_reduced_ids(MutableSpan<int> result) const
result[i] = id_by_root.lookup(result[i]);
}
});
return id_by_root.size();
}
int AtomicDisjointSet::count_sets() const