Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Limbo.Containers

Table of Contents

Introduction

Some specially designed containers for specific applications, such as disjoint set, multiple-level set, etc.

Examples

test_disjointset.cpp

#include <iostream>
int main()
{
std::vector<int> vParent (10);
std::vector<int> vRank (vParent.size());
typedef limbo::containers::DisjointSet disjoint_set_type;
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
2 ./test_disjointset

Output

1 number of sets = 7
2 parent of subset of element 4 = 4
3 number of sets = 6
4 parent of subset of element 4 = 2

References