30 # include <tpl_dynArray.H> 31 # include <tpl_dynSetTree.H> 60 virtual size_t root(
size_t i)
71 size_t depth(
size_t i) noexcept
73 const int & parent = id(i);
77 return 1 + depth(parent);
88 id.reserve(num_blocks);
90 for (
size_t i = 0; i < num_blocks; ++i)
110 size_t size() const noexcept {
return id.size(); }
130 return root(i) == root(j);
139 void join(
size_t i,
size_t j) noexcept
181 void verify_if_add_new_points(
size_t n)
189 for (
int i = l; i <= n; ++i)
194 num_blocks += n - l + 1;
197 virtual size_t root(
size_t i)
199 verify_if_add_new_points(i);
200 return Fixed_Relation::root(i);
226 template <
typename T,
class Compare = Aleph::less<T>>
236 Pair(
const T & __item,
size_t __i)
237 noexcept(std::is_nothrow_copy_assignable<T>::value)
238 : item(__item), i(__i) { }
243 bool operator () (
const Pair & p1,
const Pair & p2)
const noexcept
245 return Compare() (p1.item, p2.item);
252 size_t test_and_insert_new_item(
const T & item)
265 size_t i = test_and_insert_new_item(p);
266 size_t j = test_and_insert_new_item(q);
272 void join(
const T & p,
const T & q)
274 size_t i = test_and_insert_new_item(p);
275 size_t j = test_and_insert_new_item(q);
280 # endif // TPL_UNION_H void reserve(const size_t l, const size_t r)
Definition: tpl_dynArray.H:998
size_t size() const noexcept
Return the number of items of set (not of relation)
Definition: tpl_union.H:110
Definition: tpl_union.H:179
Definition: tpl_union.H:52
void join(size_t i, size_t j) noexcept
Definition: tpl_union.H:139
size_t get_num_blocks() const noexcept
Definition: tpl_union.H:114
bool are_connected(size_t i, size_t j) noexcept
Definition: tpl_union.H:128
bool are_connected(const T &p, const T &q)
Retorna true is i y j están conectados.
Definition: tpl_union.H:263
void join(const T &p, const T &q)
Une p con q.
Definition: tpl_union.H:272
Definition: tpl_union.H:227
void set_n(size_t n)
Definition: tpl_union.H:107
Fixed_Relation(size_t n=0)
Initialize an empty binary relation of integers between 0 and n - 1.
Definition: tpl_union.H:83
Key * search_or_insert(const Key &key)
Definition: tpl_dynSetTree.H:254
Relation(size_t n=0)
Intialize an empty relation of n elementos between [0..n)
Definition: tpl_union.H:206