00001 #ifndef UNIONFINDSIMPLE_H 00002 #define UNIONFINDSIMPLE_H 00003 00004 #include <vector> 00005 00006 namespace AprilTags { 00007 00009 class UnionFindSimple { 00011 struct Data { 00012 int id; 00013 int size; 00014 }; 00015 00016 public: 00017 explicit UnionFindSimple(int maxId) : data(maxId) { 00018 init(); 00019 }; 00020 00021 int getSetSize(int thisId) { return data[getRepresentative(thisId)].size; } 00022 00023 int getRepresentative(int thisId); 00024 00026 /* @param aId 00027 * @param bId 00028 */ 00029 int connectNodes(int aId, int bId); 00030 00031 void printDataVector() const; 00032 00033 private: 00034 void init(); 00035 00036 std::vector<Data> data; 00037 }; 00038 00039 } // namespace 00040 00041 #endif