From d5143347d97bcee8fbf6c2e8790b25cf9b905d4a Mon Sep 17 00:00:00 2001 From: Kai Ni Date: Sat, 8 May 2010 20:11:19 +0000 Subject: [PATCH] add makeUnionInPlace --- cpp/DSF.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/DSF.h b/cpp/DSF.h index 8c12b6b1b..7a05e8e2d 100644 --- a/cpp/DSF.h +++ b/cpp/DSF.h @@ -52,6 +52,9 @@ namespace gtsam { // return a new DSF where x and y are in the same set. Kai: the caml implementation is not const, and I followed Self makeUnion(const Key& key1, const Key& key2) { return this->add(findSet_(key2), findSet_(key1)); } + // the in-place version of makeUnion + void makeUnionInPlace(const Key& key1, const Key& key2) { *this = this->add(findSet_(key2), findSet_(key1)); } + // create a new singleton with two connected keys Self makePair(const Key& key1, const Key& key2) const { return makeSet(key1).makeSet(key2).makeUnion(key1, key2); }