From 71ba72038a66392f33ac02bd7878ee9d5860beca Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Mon, 13 Dec 2010 10:06:47 +0000 Subject: [PATCH] Added SimpleTree::Clear() --- map/map_tests/simple_tree_test.cpp | 5 +++++ map/simple_tree.hpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/map/map_tests/simple_tree_test.cpp b/map/map_tests/simple_tree_test.cpp index 1b37c6c60b..4d254c04f5 100644 --- a/map/map_tests/simple_tree_test.cpp +++ b/map/map_tests/simple_tree_test.cpp @@ -47,4 +47,9 @@ UNIT_TEST(SimpleTree) Calculator c3; tree[i].ForEachChildren(c3); TEST_GREATER(c3.count, c2.count, ("Europe should contain some regions")); + + tree.Clear(); + Calculator c4; + tree.ForEachChildren(c4); + TEST_EQUAL(c4.count, 0, ("Tree should be empty")); } diff --git a/map/simple_tree.hpp b/map/simple_tree.hpp index 20bcb158bb..4afeb4d272 100644 --- a/map/simple_tree.hpp +++ b/map/simple_tree.hpp @@ -43,6 +43,12 @@ public: return m_siblings.back().Value(); } + /// Deletes all children and makes tree empty + void Clear() + { + m_siblings.clear(); + } + bool operator<(SimpleTree const & other) const { return Value() < other.Value();