25 # ifndef DSGRELATION_H 26 # define DSGRELATION_H 53 template <
typename T,
class Equal = std::equal_to<T>>
60 nat_t search_or_insert(
const T & item)
const 64 if (result ==
nullptr)
67 throw std::overflow_error(
"Cannot add a new item");
75 void init_from_list(
const std::initializer_list<T> &);
90 TRelation(
const std::initializer_list<T> & list, Equal & eq)
96 TRelation(
const std::initializer_list<T> & list, Equal && eq = Equal())
98 table(list.
size() * 1.25, std::forward<Equal>(eq))
100 init_from_list(list);
103 void join(
const T & tp,
const T & tq)
105 nat_t p = search_or_insert(tp);
106 nat_t q = search_or_insert(tq);
117 p = search_or_insert(tp);
118 q = search_or_insert(tq);
122 throw std::domain_error(
"Both elements must belong to relation");
131 template <
typename T,
class Equal>
136 for (
const T & item : l)
142 # endif // DSGRELATION_H
nat_t size() const
Definition: hash.H:282
TRelation(nat_t n, Equal &&eq=Equal())
Definition: relation.H:84
TRelation(const std::initializer_list< T > &list, Equal &&eq=Equal())
Definition: relation.H:96
bool are_connected(const T &tp, const T &tq) const
Definition: relation.H:111
Definition: relation.H:33
EquivalenceRelation(nat_t)
Value * insert(const Key &k, const Value &v)
Definition: map.H:186
nat_t get_num_blocks() const
TRelation(nat_t n, Equal &eq)
Definition: relation.H:78
unsigned long int nat_t
Definition: types.H:50
Definition: relation.H:54
Value * search(const Key &k)
Definition: map.H:254
bool are_connected(nat_t, nat_t) const
void join(const T &tp, const T &tq)
Definition: relation.H:103
TRelation(const std::initializer_list< T > &list, Equal &eq)
Definition: relation.H:90