25 #ifndef _TOOLBOX_UNIONFIND_HPP
26 #define _TOOLBOX_UNIONFIND_HPP
58 virtual T
find(T x) = 0;
65 typedef typename std::set<T>
SetTy;
70 typename SetSetTy::iterator
find_it(T x) {
71 for (
typename SetSetTy::iterator
i =
sets.begin(),
e =
sets.end();
74 if (std::find(set.begin(),set.end(),x) != set.end()) {
84 assert(
find(s) ==
end() &&
"Element already in a set!");
92 typename SetSetTy::iterator r_it, s_it;
97 return *(r_it->begin());
98 if ( r_it ==
sets.end() || s_it ==
sets.end() )
101 merged.insert(s_it->begin(), s_it->end());
102 merged.insert(r_it->begin(), r_it->end());
113 return *merged.begin();
117 typename SetSetTy::iterator
i =
find_it(x);
120 return *(*i).begin();
virtual T find(T x)
find the repres to of a given element x
virtual void make_set(T s)
Create a new set.
virtual T find(T x)=0
find the repres to of a given element x
virtual T set_union(T r, T s)=0
union the set that contains r with the set that contains s
SetSetTy::iterator find_it(T x)
virtual T set_union(T r, T s)
union the set that contains r with the set that contains s
std::set< SetTy > SetSetTy
virtual void make_set(T s)=0
Create a new set.