fixed a potential bug

release/4.3a0
Kai Ni 2010-06-23 03:09:26 +00:00
parent d7221c9cc5
commit 676a74a0ac
2 changed files with 20 additions and 3 deletions

View File

@ -109,11 +109,13 @@ namespace gtsam {
return partitions; return partitions;
} }
// get the nodes in the given tree // get the nodes in the tree with the given label
Set set(const Label& label) { Set set(const Label& label) {
Set set; Set set;
BOOST_FOREACH(const KeyLabel& pair, (Tree)*this) BOOST_FOREACH(const KeyLabel& pair, (Tree)*this) {
if (pair.second==label) set.insert(pair.first); if (pair.second == label || findSet(pair.second) == label)
set.insert(pair.first);
}
return set; return set;
} }

View File

@ -195,6 +195,21 @@ TEST(DSF, set) {
CHECK(expected == set); CHECK(expected == set);
} }
/* ************************************************************************* */
TEST(DSF, set2) {
DSFInt dsf;
dsf = dsf.makeSet(5);
dsf = dsf.makeSet(6);
dsf = dsf.makeSet(7);
dsf = dsf.makeUnion(5,6);
dsf = dsf.makeUnion(6,7);
set<int> set = dsf.set(5);
LONGS_EQUAL(3, set.size());
std::set<int> expected; expected += 5, 6, 7;
CHECK(expected == set);
}
/* ************************************************************************* */ /* ************************************************************************* */
int func(const int& a) { return a + 10; } int func(const int& a) { return a + 10; }
TEST(DSF, map) { TEST(DSF, map) {