23 #ifndef ICL_CORE_UNION_FIND_H_INCLUDED 24 #define ICL_CORE_UNION_FIND_H_INCLUDED 40 for (std::size_t i = 0; i < n; ++i)
47 void grow(
const std::size_t n = 1)
49 std::size_t old_size =
m_parent.size();
52 for (std::size_t i = old_size; i <
m_parent.size(); ++i)
61 void merge(std::size_t x, std::size_t y)
65 throw std::out_of_range(
"index out of range");
88 std::size_t
find(std::size_t x)
92 throw std::out_of_range(
"index out of range");
void merge(std::size_t x, std::size_t y)
std::vector< std::size_t > m_rank
std::size_t find(std::size_t x)
UnionFind(const std::size_t n)
void grow(const std::size_t n=1)
Enlarges the data structure by n elements.
std::vector< std::size_t > m_parent