16 for (
const int i :
range) {
17 items_[i].store(Item{i, 0}, relaxed);
26 [&](
int *first_occurrence) { *first_occurrence = index; },
27 [&](
int *first_occurrence) {
28 if (index < *first_occurrence) {
29 *first_occurrence = index;
38 const int size = result.size();
45 for (
const int i :
range) {
54 for (
const Map<int, int> &other_map : first_occurrence_by_root_per_thread) {
55 if (&combined_map == &other_map) {
58 for (
const auto item : other_map.items()) {
63 struct RootOccurence {
70 root_occurrences.
reserve(combined_map.size());
71 for (
const auto item : combined_map.items()) {
72 root_occurrences.
append({item.key, item.value});
75 root_occurrences.
end(),
76 [](
const RootOccurence &a,
const RootOccurence &
b) {
77 return a.first_occurrence < b.first_occurrence;
83 for (
const int i : root_occurrences.
index_range()) {
84 id_by_root.
add_new(root_occurrences[i].root, i);
87 for (
const int i :
range) {
88 result[i] = id_by_root.
lookup(result[i]);
91 return id_by_root.
size();
101 for (const int i : range) {
102 if (this->is_root(i)) {
108 [](
const int a,
const int b) {
return a +
b; });
IndexRange index_range() const
int calc_reduced_ids(MutableSpan< int > result) const
AtomicDisjointSet(const int size)
int find_root(int x) const
const Value & lookup(const Key &key) const
void add_new(const Key &key, const Value &value)
void append(const T &value)
IndexRange index_range() const
void reserve(const int64_t min_capacity)
local_group_size(16, 16) .push_constant(Type b
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
static void update_first_occurrence(Map< int, int > &map, const int root, const int index)
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)