19 #include <boost/shared_ptr.hpp> 20 #include <boost/assign/std/list.hpp> 27 using namespace gtsam;
29 typedef pair<size_t, size_t>
Range;
33 static std::stringstream
ss;
34 static string x1(
"x1"),
x2(
"x2"),
x3(
"x3"),
x4(
"x4"),
x5(
"x5");
43 void g(
const string&
key,
int i) {
47 int add(
const string& k,
int v,
int a) {
101 CHECK(!tree2.same(tree1))
106 CHECK(!tree3.same(tree1))
107 CHECK(!tree3.same(tree2))
111 CHECK(!tree4.same(tree1))
116 CHECK(tree5.same(tree1))
117 CHECK(!tree5.same(tree2))
127 CHECK(
ss.str() == string(
"x1x2x3x4x5"));
137 CHECK(it->second == 1)
157 copy (tree.begin(),tree.end(),back_inserter(actual));
158 CHECK(actual==expected)
176 list<RangeTree::value_type>
expected;
178 for (
int i = 1;
i <=
N;
i++) {
181 tree = tree.
add(key, value);
184 expected += make_pair(key, value);
191 list<RangeTree::value_type> actual;
193 CHECK(actual==expected)
196 for (
int i = N;
i >=
N;
i--) {
BTree add(const value_type &xd) const
static int runAllTests(TestResult &result)
int f(const string &key, const Range &range)
BTree< string, int > IntTree
purely functional binary tree
void g(const string &key, int i)
bool mem(const KEY &x) const
Const iterator Not trivial: iterator keeps a stack to indicate current path from root_.
bool equality(const T &input=T())
void iter(boost::function< void(const KEY &, const VALUE &)> f) const
ACC fold(boost::function< ACC(const KEY &, const VALUE &, const ACC &)> f, const ACC &a) const
const_iterator begin() const
bool same(const BTree &other) const
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
BTree< string, Range > RangeTree
pair< size_t, size_t > Range
const VALUE & find(const KEY &k) const
static std::stringstream ss
#define LONGS_EQUAL(expected, actual)
BTree< KEY, TO > map(boost::function< TO(const KEY &, const VALUE &)> f) const
const_iterator end() const
BTree remove(const KEY &x) const
int add(const string &k, int v, int a)
pair< string, int > KeyInt