feat(util/trie): add value() method

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-06-03 01:19:23 -07:00
parent ab5f570924
commit 5a5d66edc8
2 changed files with 7 additions and 0 deletions

View file

@ -29,8 +29,11 @@ static void tst1() {
lean_assert(!find(t, "abd"));
t2.display(std::cout);
ctrie<int> t3 = *t2.find('a');
lean_assert(!t3.value());
lean_assert(*find(t3, "bc") == 10);
lean_assert(*find(t3, "bd") == 11);
ctrie<int> t4 = *(t3.find('b')->find('c'));
lean_assert(*t4.value() == 10);
}
static void tst2() {

View file

@ -130,6 +130,10 @@ public:
return optional<trie>();
}
optional<Val> value() const {
return m_root->m_value;
}
void merge(trie const & t) {
m_root = merge(m_root.steal(), t.m_root);
}