From e3cf285ee787259bf438f1ee2cfcb19fd6061e0f Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Tue, 9 Aug 2016 03:50:56 +0000 Subject: [PATCH] table: delete deprecated functions in NameTree NameTree::eraseEntryIfEmpty is renamed to eraseIfEmpty; the deprecated overload that accepts shared_ptr is deleted. name_tree::Entry::getPrefix is deleted in favor of getName. This commit also improves Doxygen in NameTree class. refs #3687 Change-Id: Ia98ca676ce6d3bc7b2e97328adccac911c8167d7 --- daemon/table/cleanup.cpp | 4 +- daemon/table/fib.cpp | 2 +- daemon/table/measurements.cpp | 4 +- daemon/table/name-tree-entry.hpp | 7 -- daemon/table/name-tree-iterator.cpp | 4 +- daemon/table/name-tree.cpp | 17 ++-- daemon/table/name-tree.hpp | 146 ++++++++++++++-------------- daemon/table/pit.cpp | 2 +- daemon/table/strategy-choice.cpp | 4 +- tests/daemon/table/name-tree.t.cpp | 48 +++++---- 10 files changed, 114 insertions(+), 124 deletions(-) diff --git a/daemon/table/cleanup.cpp b/daemon/table/cleanup.cpp index 0ba07253..8317099b 100644 --- a/daemon/table/cleanup.cpp +++ b/daemon/table/cleanup.cpp @@ -44,7 +44,7 @@ cleanupOnFaceRemoval(NameTree& nt, Fib& fib, Pit& pit, const Face& face) } if (nte.getFibEntry() == nullptr && !nte.hasPitEntries()) { - maybeEmptyNtes.emplace(nte.getPrefix().size(), const_pointer_cast(nte.shared_from_this())); + maybeEmptyNtes.emplace(nte.getName().size(), const_pointer_cast(nte.shared_from_this())); } } @@ -53,7 +53,7 @@ cleanupOnFaceRemoval(NameTree& nt, Fib& fib, Pit& pit, const Face& face) shared_ptr nte = i->second.lock(); // nte may have been erased when its last child is erased if (nte != nullptr) { - nt.eraseEntryIfEmpty(nte); + nt.eraseIfEmpty(nte.get()); } } } diff --git a/daemon/table/fib.cpp b/daemon/table/fib.cpp index 890bbbe7..d18ce948 100644 --- a/daemon/table/fib.cpp +++ b/daemon/table/fib.cpp @@ -136,7 +136,7 @@ Fib::erase(shared_ptr nte, bool canDeleteNte) nte->setFibEntry(nullptr); if (canDeleteNte) { - m_nameTree.eraseEntryIfEmpty(nte); + m_nameTree.eraseIfEmpty(nte.get()); } --m_nItems; } diff --git a/daemon/table/measurements.cpp b/daemon/table/measurements.cpp index c939b724..d93cc918 100644 --- a/daemon/table/measurements.cpp +++ b/daemon/table/measurements.cpp @@ -45,7 +45,7 @@ Measurements::get(name_tree::Entry& nte) return *entry; } - nte.setMeasurementsEntry(make_unique(nte.getPrefix())); + nte.setMeasurementsEntry(make_unique(nte.getName())); ++m_nItems; entry = nte.getMeasurementsEntry(); @@ -165,7 +165,7 @@ Measurements::cleanup(Entry& entry) BOOST_ASSERT(nte != nullptr); nte->setMeasurementsEntry(nullptr); - m_nameTree.eraseEntryIfEmpty(nte); + m_nameTree.eraseIfEmpty(nte.get()); --m_nItems; } diff --git a/daemon/table/name-tree-entry.hpp b/daemon/table/name-tree-entry.hpp index 9875891a..576139c2 100644 --- a/daemon/table/name-tree-entry.hpp +++ b/daemon/table/name-tree-entry.hpp @@ -48,13 +48,6 @@ public: return m_name; } - /// \deprecated - const Name& - getPrefix() const - { - return this->getName(); - } - /** \return entry of getName().getPrefix(-1) * \retval nullptr this entry is the root entry, i.e. getName() == Name() */ diff --git a/daemon/table/name-tree-iterator.cpp b/daemon/table/name-tree-iterator.cpp index 9832dcdc..e62060a4 100644 --- a/daemon/table/name-tree-iterator.cpp +++ b/daemon/table/name-tree-iterator.cpp @@ -90,12 +90,12 @@ operator<<(std::ostream& os, const Iterator& i) return os << "uninitialized"; } - os << "entry=" << i.m_entry->getPrefix(); + os << "entry=" << i.m_entry->getName(); if (i.m_ref == nullptr) { os << " ref=null"; } else { - os << " ref=" << i.m_ref->getPrefix(); + os << " ref=" << i.m_ref->getName(); } os << " state=" << i.m_state; return os; diff --git a/daemon/table/name-tree.cpp b/daemon/table/name-tree.cpp index bbe57844..993a58ab 100644 --- a/daemon/table/name-tree.cpp +++ b/daemon/table/name-tree.cpp @@ -77,12 +77,12 @@ NameTree::lookup(const pit::Entry& pitEntry) return nullptr; } - if (nte->getPrefix().size() == pitEntry.getName().size()) { + if (nte->getName().size() == pitEntry.getName().size()) { return nte; } BOOST_ASSERT(pitEntry.getName().at(-1).isImplicitSha256Digest()); - BOOST_ASSERT(nte->getPrefix() == pitEntry.getName().getPrefix(-1)); + BOOST_ASSERT(nte->getName() == pitEntry.getName().getPrefix(-1)); return this->lookup(pitEntry.getName()); } @@ -103,7 +103,7 @@ NameTree::lookup(const strategy_choice::Entry& strategyChoiceEntry) const } size_t -NameTree::eraseEntryIfEmpty(Entry* entry) +NameTree::eraseIfEmpty(Entry* entry) { BOOST_ASSERT(entry != nullptr); @@ -167,21 +167,20 @@ NameTree::findLongestPrefixMatch(const pit::Entry& pitEntry) const { shared_ptr nte = this->getEntry(pitEntry); BOOST_ASSERT(nte != nullptr); - if (nte->getPrefix().size() == pitEntry.getName().size()) { + if (nte->getName().size() == pitEntry.getName().size()) { return nte; } BOOST_ASSERT(pitEntry.getName().at(-1).isImplicitSha256Digest()); - BOOST_ASSERT(nte->getPrefix() == pitEntry.getName().getPrefix(-1)); + BOOST_ASSERT(nte->getName() == pitEntry.getName().getPrefix(-1)); shared_ptr exact = this->findExactMatch(pitEntry.getName()); return exact == nullptr ? nte : exact; } boost::iterator_range -NameTree::findAllMatches(const Name& prefix, - const EntrySelector& entrySelector) const +NameTree::findAllMatches(const Name& name, const EntrySelector& entrySelector) const { - NFD_LOG_TRACE("NameTree::findAllMatches" << prefix); + NFD_LOG_TRACE("NameTree::findAllMatches" << name); // As we are using Name Prefix Hash Table, and the current LPM() is // implemented as starting from full name, and reduce the number of @@ -189,7 +188,7 @@ NameTree::findAllMatches(const Name& prefix, // For trie-like design, it could be more efficient by walking down the // trie from the root node. - shared_ptr entry = findLongestPrefixMatch(prefix, entrySelector); + shared_ptr entry = findLongestPrefixMatch(name, entrySelector); return {Iterator(make_shared(*this, entrySelector), entry.get()), end()}; } diff --git a/daemon/table/name-tree.hpp b/daemon/table/name-tree.hpp index ad9f3143..d630cad7 100644 --- a/daemon/table/name-tree.hpp +++ b/daemon/table/name-tree.hpp @@ -31,6 +31,8 @@ namespace nfd { namespace name_tree { +/** \brief a common index structure for FIB, PIT, StrategyChoice, and Measurements + */ class NameTree : noncopyable { public: @@ -40,7 +42,7 @@ public: NameTree(size_t nBuckets = 1024); public: // information - /** \brief Get the number of occupied entries in the Name Tree + /** \return number of name tree entries */ size_t size() const @@ -48,10 +50,7 @@ public: // information return m_ht.size(); } - /** \brief Get the number of buckets in the Name Tree (NPHT) - * - * The number of buckets is the one that used to create the hash - * table, i.e., m_nBuckets. + /** \return number of hashtable buckets */ size_t getNBuckets() const @@ -59,7 +58,7 @@ public: // information return m_ht.getNBuckets(); } - /** \return Name Tree Entry on which a table entry is attached + /** \return entry on which a table entry is attached */ template shared_ptr @@ -69,149 +68,152 @@ public: // information } public: // mutation - /** \brief Look for the Name Tree Entry that contains this name prefix. - * - * Starts from the shortest name prefix, and then increase the - * number of name components by one each time. All non-existing Name Tree - * Entries will be created. - * - * \param name The querying name prefix. - * \return The pointer to the Name Tree Entry that contains this full name prefix. + /** \brief find or insert an entry with specified name + * \param name a name prefix + * \return an entry with \p name + * \post an entry with \p name and all ancestors are created * \note Existing iterators are unaffected. */ shared_ptr lookup(const Name& name); - /** \brief get NameTree entry from FIB entry - * - * This is equivalent to .lookup(fibEntry.getPrefix()) + /** \brief equivalent to .lookup(fibEntry.getPrefix()) + * \note This overload is more efficient than .lookup(const Name&) in common cases. */ shared_ptr lookup(const fib::Entry& fibEntry) const; - /** \brief get NameTree entry from PIT entry - * - * This is equivalent to .lookup(pitEntry.getName()). + /** \brief equivalent to .lookup(pitEntry.getName()). + * \note This overload is more efficient than .lookup(const Name&) in common cases. */ shared_ptr lookup(const pit::Entry& pitEntry); - /** \brief get NameTree entry from Measurements entry - * - * This is equivalent to .lookup(measurementsEntry.getName()) + /** \brief equivalent to .lookup(measurementsEntry.getName()) + * \note This overload is more efficient than .lookup(const Name&) in common cases. */ shared_ptr lookup(const measurements::Entry& measurementsEntry) const; - /** \brief get NameTree entry from StrategyChoice entry - * - * This is equivalent to .lookup(strategyChoiceEntry.getName()) + /** \brief equivalent to .lookup(strategyChoiceEntry.getName()) + * \note This overload is more efficient than .lookup(const Name&) in common cases. */ shared_ptr lookup(const strategy_choice::Entry& strategyChoiceEntry) const; - /** \brief Delete a Name Tree Entry if this entry is empty. - * \param entry The entry to be deleted if empty. - * \note This function must be called after a table entry is detached from Name Tree - * entry. The function deletes a Name Tree entry if nothing is attached to it and - * it has no children, then repeats the same process on its ancestors. + /** \brief delete the entry if it is empty + * \param entry a valid entry + * \return number of deleted entries + * \sa Entry::isEmpty() + * \post If the entry is empty, it's deleted. + * Ancestors of the entry are also deleted if they become empty. + * \note This function must be called after detaching a table entry from a name tree entry, * \note Existing iterators, except those pointing to deleted entries, are unaffected. */ size_t - eraseEntryIfEmpty(Entry* entry); - - /// \deprecated - bool - eraseEntryIfEmpty(shared_ptr entry) - { - BOOST_ASSERT(entry != nullptr); - return this->eraseEntryIfEmpty(entry.get()) > 0; - } + eraseIfEmpty(Entry* entry); public: // matching - /** \brief Exact match lookup for the given name prefix. - * \return nullptr if this prefix is not found; otherwise return the Name Tree Entry address + /** \brief exact match lookup + * \return entry with \p name, or nullptr if it does not exist */ shared_ptr findExactMatch(const Name& name) const; - /** \brief Longest prefix matching for the given name - * - * Starts from the full name string, reduce the number of name component - * by one each time, until an Entry is found. + /** \brief longest prefix matching + * \return entry whose name is a prefix of \p name and passes \p entrySelector, + * where no other entry with a longer name satisfies those requirements; + * or nullptr if no entry satisfying those requirements exists */ shared_ptr findLongestPrefixMatch(const Name& name, const EntrySelector& entrySelector = AnyEntry()) const; + /** \brief equivalent to .findLongestPrefixMatch(entry->getName(), entrySelector) + * \note This overload is more efficient than .findLongestPrefixMatch(const Name&) + * in common cases. + */ shared_ptr findLongestPrefixMatch(shared_ptr entry, const EntrySelector& entrySelector = AnyEntry()) const; - /** \brief longest prefix matching for Interest name of the PIT entry - * - * This is equivalent to .findLongestPrefixMatch(pitEntry.getName(), AnyEntry()). + /** \brief equivalent to .findLongestPrefixMatch(pitEntry.getName(), AnyEntry()) + * \note This overload is more efficient than .findLongestPrefixMatch(const Name&) + * in common cases. */ shared_ptr findLongestPrefixMatch(const pit::Entry& pitEntry) const; - /** \brief Enumerate all the name prefixes that satisfy the prefix and entrySelector + /** \brief all-prefixes match lookup * \return an unspecified type that have .begin() and .end() methods - * and is usable with range-based for + * and is usable with range-based for. + * Every entry in the range has a name that is a prefix of \p name , + * and matches \p entrySelector. * * Example: - * \code{.cpp} - * auto&& allMatches = nt.findAllMatches(Name("/A/B/C")); + * \code + * Name name("/A/B/C"); + * auto&& allMatches = nt.findAllMatches(name); * for (const Entry& nte : allMatches) { + * BOOST_ASSERT(nte.getName().isPrefixOf(name)); * ... * } * \endcode - * \note Iteration order is implementation-specific and is undefined - * \note The returned iterator may get invalidated when NameTree is modified + * \note Iteration order is implementation-specific and is undefined. + * \warning If a name tree entry whose name is a prefix of \p name is inserted + * during the enumeration, it may or may not be visited. + * If a name tree entry whose name is a prefix of \p name is deleted + * during the enumeration, undefined behavior may occur. */ boost::iterator_range - findAllMatches(const Name& prefix, + findAllMatches(const Name& name, const EntrySelector& entrySelector = AnyEntry()) const; public: // enumeration - /** \brief Enumerate all entries, optionally filtered by an EntrySelector. + /** \brief enumerate all entries * \return an unspecified type that have .begin() and .end() methods - * and is usable with range-based for + * and is usable with range-based for. + * Every entry in the range matches \p entrySelector. * * Example: - * \code{.cpp} + * \code * auto&& enumerable = nt.fullEnumerate(); * for (const Entry& nte : enumerable) { * ... * } * \endcode - * \note Iteration order is implementation-specific and is undefined - * \note The returned iterator may get invalidated when NameTree is modified + * \note Iteration order is implementation-specific and is undefined. + * \warning If a name tree entry is inserted or deleted during the enumeration, + * it may cause the enumeration to skip entries or visit some entries twice. */ boost::iterator_range fullEnumerate(const EntrySelector& entrySelector = AnyEntry()) const; - /** \brief Enumerate all entries under a prefix, optionally filtered by an EntrySubTreeSelector. + /** \brief enumerate all entries under a prefix * \return an unspecified type that have .begin() and .end() methods - * and is usable with range-based for + * and is usable with range-based for. + * Every entry in the range has a name that starts with \p prefix, + * and matches \p entrySubTreeSelector. * * Example: - * \code{.cpp} - * auto&& enumerable = nt.partialEnumerate(Name("/A/B/C")); + * \code + * Name name("/A/B/C"); + * auto&& enumerable = nt.partialEnumerate(name); * for (const Entry& nte : enumerable) { + * BOOST_ASSERT(name.isPrefixOf(nte.getName())); * ... * } * \endcode - * \note Iteration order is implementation-specific and is undefined - * \note The returned iterator may get invalidated when NameTree is modified + * \note Iteration order is implementation-specific and is undefined. + * \warning If a name tree entry under \p prefix is inserted or deleted during the enumeration, + * it may cause the enumeration to skip entries or visit some entries twice. */ boost::iterator_range partialEnumerate(const Name& prefix, const EntrySubTreeSelector& entrySubTreeSelector = AnyEntrySubTree()) const; - /** \brief Get an iterator pointing to the first NameTree entry - * \note Iteration order is implementation-specific and is undefined - * \note The returned iterator may get invalidated when NameTree is modified + /** \return an iterator to enumerate all entries + * \sa fullEnumerate */ const_iterator begin() const @@ -219,9 +221,7 @@ public: // enumeration return fullEnumerate().begin(); } - /** \brief Get an iterator referring to the past-the-end FIB entry - * \note Iteration order is implementation-specific and is undefined - * \note The returned iterator may get invalidated when NameTree is modified + /** \return a past-the-end iterator */ const_iterator end() const diff --git a/daemon/table/pit.cpp b/daemon/table/pit.cpp index 57cbf537..de6c9da5 100644 --- a/daemon/table/pit.cpp +++ b/daemon/table/pit.cpp @@ -137,7 +137,7 @@ Pit::erase(shared_ptr entry, bool canDeleteNte) nte->erasePitEntry(entry); if (canDeleteNte) { - m_nameTree.eraseEntryIfEmpty(nte); + m_nameTree.eraseIfEmpty(nte.get()); } --m_nItems; } diff --git a/daemon/table/strategy-choice.cpp b/daemon/table/strategy-choice.cpp index 3c701d46..a8b32d7c 100644 --- a/daemon/table/strategy-choice.cpp +++ b/daemon/table/strategy-choice.cpp @@ -145,7 +145,7 @@ StrategyChoice::erase(const Name& prefix) this->changeStrategy(*entry, oldStrategy, parentStrategy); nte->setStrategyChoiceEntry(nullptr); - m_nameTree.eraseEntryIfEmpty(nte); + m_nameTree.eraseIfEmpty(nte.get()); --m_nItems; } @@ -229,7 +229,7 @@ StrategyChoice::setDefaultStrategy(unique_ptr strategy) static inline void clearStrategyInfo(const name_tree::Entry& nte) { - NFD_LOG_TRACE("clearStrategyInfo " << nte.getPrefix()); + NFD_LOG_TRACE("clearStrategyInfo " << nte.getName()); for (const shared_ptr& pitEntry : nte.getPitEntries()) { pitEntry->clearStrategyInfo(); diff --git a/tests/daemon/table/name-tree.t.cpp b/tests/daemon/table/name-tree.t.cpp index f87b50f9..4c030ace 100644 --- a/tests/daemon/table/name-tree.t.cpp +++ b/tests/daemon/table/name-tree.t.cpp @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE(NameTreeEntry) auto node = make_unique(0, prefix); shared_ptr npe = node->entry; - BOOST_CHECK_EQUAL(npe->getPrefix(), prefix); + BOOST_CHECK_EQUAL(npe->getName(), prefix); // examine all the get methods @@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE(Basic) bool eraseResult = false; temp = nt.findExactMatch(nameABC); if (temp != nullptr) - eraseResult = nt.eraseEntryIfEmpty(temp); + eraseResult = nt.eraseIfEmpty(temp.get()); BOOST_CHECK_EQUAL(nt.size(), 6); BOOST_CHECK(nt.findExactMatch(nameABC) == nullptr); BOOST_CHECK_EQUAL(eraseResult, true); @@ -320,20 +320,18 @@ BOOST_AUTO_TEST_CASE(Basic) eraseResult = false; temp = nt.findExactMatch(nameABCLPM); if (temp != nullptr) - eraseResult = nt.eraseEntryIfEmpty(temp); + eraseResult = nt.eraseIfEmpty(temp.get()); BOOST_CHECK(temp == nullptr); BOOST_CHECK_EQUAL(nt.size(), 6); BOOST_CHECK_EQUAL(eraseResult, false); - // nt.dump(std::cout); - nt.lookup(nameABC); BOOST_CHECK_EQUAL(nt.size(), 7); eraseResult = false; temp = nt.findExactMatch(nameABC); if (temp != nullptr) - eraseResult = nt.eraseEntryIfEmpty(temp); + eraseResult = nt.eraseIfEmpty(temp.get()); BOOST_CHECK_EQUAL(nt.size(), 6); BOOST_CHECK_EQUAL(eraseResult, true); BOOST_CHECK(nt.findExactMatch(nameABC) == nullptr); @@ -350,22 +348,22 @@ BOOST_AUTO_TEST_CASE(Basic) // try to erase /a/b/c, should return false temp = nt.findExactMatch(nameABC); - BOOST_CHECK_EQUAL(temp->getPrefix(), nameABC); - eraseResult = nt.eraseEntryIfEmpty(temp); + BOOST_CHECK_EQUAL(temp->getName(), nameABC); + eraseResult = nt.eraseIfEmpty(temp.get()); BOOST_CHECK_EQUAL(eraseResult, false); temp = nt.findExactMatch(nameABC); - BOOST_CHECK_EQUAL(temp->getPrefix(), nameABC); + BOOST_CHECK_EQUAL(temp->getName(), nameABC); temp = nt.findExactMatch(nameABD); if (temp != nullptr) - nt.eraseEntryIfEmpty(temp); + nt.eraseIfEmpty(temp.get()); BOOST_CHECK_EQUAL(nt.size(), 8); } /** \brief verify a NameTree enumeration contains expected entries * * Example: - * \code{.cpp} + * \code * auto& enumerable = ...; * EnumerationVerifier(enumerable) * .expect("/A") @@ -381,7 +379,7 @@ public: EnumerationVerifier(Enumerable&& enumerable) { for (const Entry& entry : enumerable) { - const Name& name = entry.getPrefix(); + const Name& name = entry.getName(); BOOST_CHECK_MESSAGE(m_names.insert(name).second, "duplicate Name " << name); } } @@ -497,7 +495,7 @@ BOOST_AUTO_TEST_CASE(OnlyA) // Accept "root" nameA only auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) { - return std::make_pair(entry.getPrefix() == "/a", true); + return std::make_pair(entry.getName() == "/a", true); }); EnumerationVerifier(enumerable) @@ -511,7 +509,7 @@ BOOST_AUTO_TEST_CASE(ExceptA) // Accept anything except "root" nameA auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) { - return std::make_pair(entry.getPrefix() != "/a", true); + return std::make_pair(entry.getName() != "/a", true); }); EnumerationVerifier(enumerable) @@ -527,7 +525,7 @@ BOOST_AUTO_TEST_CASE(NoNameANoSubTreeAB) // No NameA // No SubTree from NameAB auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) { - return std::make_pair(entry.getPrefix() != "/a", entry.getPrefix() != "/a/b"); + return std::make_pair(entry.getName() != "/a", entry.getName() != "/a/b"); }); EnumerationVerifier(enumerable) @@ -545,7 +543,7 @@ BOOST_AUTO_TEST_CASE(NoNameANoSubTreeAC) // No NameA // No SubTree from NameAC auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) { - return std::make_pair(entry.getPrefix() != "/a", entry.getPrefix() != "/a/c"); + return std::make_pair(entry.getName() != "/a", entry.getName() != "/a/c"); }); EnumerationVerifier(enumerable) @@ -562,7 +560,7 @@ BOOST_AUTO_TEST_CASE(NoSubTreeA) // No Subtree from NameA auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) { - return std::make_pair(true, entry.getPrefix() != "/a"); + return std::make_pair(true, entry.getName() != "/a"); }); EnumerationVerifier(enumerable) @@ -593,7 +591,7 @@ BOOST_AUTO_TEST_CASE(Example) bool visitEntry = false; bool visitChildren = false; - Name name = entry.getPrefix(); + Name name = entry.getName(); if (name == "/" || name == "/A/B" || name == "/A/B/C" || name == "/A/D") { visitEntry = true; @@ -645,7 +643,7 @@ BOOST_AUTO_TEST_CASE(HashTableResizeShrink) BOOST_CHECK_EQUAL(nameTree.size(), 9); BOOST_CHECK_EQUAL(nameTree.getNBuckets(), 32); - nameTree.eraseEntryIfEmpty(entry); + nameTree.eraseIfEmpty(entry.get()); BOOST_CHECK_EQUAL(nameTree.size(), 0); BOOST_CHECK_EQUAL(nameTree.getNBuckets(), 16); } @@ -660,8 +658,8 @@ BOOST_AUTO_TEST_CASE(SurvivedIteratorAfterLookup) Name nameB("/A/B"); std::set seenNames; for (NameTree::const_iterator it = nt.begin(); it != nt.end(); ++it) { - BOOST_CHECK(seenNames.insert(it->getPrefix()).second); - if (it->getPrefix() == nameB) { + BOOST_CHECK(seenNames.insert(it->getName()).second); + if (it->getName() == nameB) { nt.lookup("/D"); } } @@ -676,7 +674,7 @@ BOOST_AUTO_TEST_CASE(SurvivedIteratorAfterLookup) BOOST_CHECK(seenNames.size() == 5); } -// .eraseEntryIfEmpty should not invalidate iterator +// .eraseIfEmpty should not invalidate iterator BOOST_AUTO_TEST_CASE(SurvivedIteratorAfterErase) { NameTree nt; @@ -688,9 +686,9 @@ BOOST_AUTO_TEST_CASE(SurvivedIteratorAfterErase) Name nameD("/A/D"); std::set seenNames; for (NameTree::const_iterator it = nt.begin(); it != nt.end(); ++it) { - BOOST_CHECK(seenNames.insert(it->getPrefix()).second); - if (it->getPrefix() == nameD) { - nt.eraseEntryIfEmpty(nt.findExactMatch("/A/F/G")); // /A/F/G and /A/F are erased + BOOST_CHECK(seenNames.insert(it->getName()).second); + if (it->getName() == nameD) { + nt.eraseIfEmpty(nt.findExactMatch("/A/F/G").get()); // /A/F/G and /A/F are erased } }