Introduction
Some specially designed containers for specific applications, such as disjoint set, multiple-level set, etc.
Examples
test_disjointset.cpp
#include <iostream>
{
std::vector<int> vParent (10);
std::vector<int> vRank (vParent.size());
disjoint_set_type::SubsetHelper<int, int> gp (vParent, vRank);
disjoint_set_type::union_set(gp, 2, 3);
disjoint_set_type::union_set(gp, 4, 6);
disjoint_set_type::union_set(gp, 5, 8);
std::cout << "number of sets = " << disjoint_set_type::count_sets(gp) << std::endl;
std::cout << "parent of subset of element 4 = " << disjoint_set_type::find_set(gp, 4) << std::endl;
disjoint_set_type::union_set(gp, 2, 4);
std::cout << "number of sets = " << disjoint_set_type::count_sets(gp) << std::endl;
std::cout << "parent of subset of element 4 = " << disjoint_set_type::find_set(gp, 4) << std::endl;
return 0;
}
Compiling and running commands (assuming LIMBO_DIR is exported as the environment variable to the path where limbo library is installed)
1 g++ -o test_disjointset test_disjointset.cpp -I $LIMBO_DIR/include
Output
2 parent of subset of element 4 = 4
4 parent of subset of element 4 = 2
References