Disjoint Set

June 5, 2015 at 05:07 pm

For my Freetron program I wanted to speed up my connected-component labeling algorithm, so I rewrote it to use a Disjoint Set.

Download
test.cpp
disjointset.h

Usage
DisjointSet<int> ds(0);
ds.add(5);
ds.add(6);
ds.add(7);

int rep = ds.find(6);

See the top of the file for more detail on how to use this.

Testing
To build and run the test:

[garrett disjointset]$ g++ test.cpp -std=c++11 -o test
[garrett disjointset]$ ./test
...