table: declare name_tree::Range type

Declare that NameTree enumeration returns name_tree::Range type
instead of an unspecified type usable with range-based for.

refs #3738

Change-Id: I132c583704d0c6164077abf70a694e833b448e85
This commit is contained in:
Junxiao Shi
2016-08-15 04:50:29 +00:00
parent dbef6dc8e2
commit 9f6ca60f74
3 changed files with 20 additions and 16 deletions
+5 -2
View File
@@ -29,17 +29,20 @@
#include <boost/concept/assert.hpp>
#include <boost/concept_check.hpp>
#include <boost/range/concepts.hpp>
#include <type_traits>
namespace nfd {
namespace name_tree {
NFD_LOG_INIT("NameTreeIterator");
BOOST_CONCEPT_ASSERT((boost::ForwardIterator<Iterator>));
static_assert(std::is_default_constructible<Iterator>::value,
"Iterator must be default-constructible");
BOOST_CONCEPT_ASSERT((boost::ForwardRangeConcept<Range>));
NFD_LOG_INIT("NameTreeIterator");
Iterator::Iterator()
: m_entry(nullptr)
, m_ref(nullptr)
+7
View File
@@ -195,6 +195,13 @@ private:
EntrySelector m_pred;
};
/** \brief a Forward Range of name tree entries
*
* This type has .begin() and .end() methods which return Iterator.
* This type is usable with range-based for.
*/
typedef boost::iterator_range<Iterator> Range;
} // namespace name_tree
} // namespace nfd
+8 -14
View File
@@ -36,8 +36,6 @@ namespace name_tree {
class NameTree : noncopyable
{
public:
typedef Iterator const_iterator;
explicit
NameTree(size_t nBuckets = 1024);
@@ -164,9 +162,7 @@ public: // matching
const EntrySelector& entrySelector = AnyEntry()) const;
/** \brief all-prefixes match lookup
* \return an unspecified type that have .begin() and .end() methods
* and is usable with range-based for.
* Every entry in the range has a name that is a prefix of \p name ,
* \return a range where every entry has a name that is a prefix of \p name ,
* and matches \p entrySelector.
*
* Example:
@@ -184,15 +180,15 @@ public: // matching
* 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<const_iterator>
Range
findAllMatches(const Name& name,
const EntrySelector& entrySelector = AnyEntry()) const;
public: // enumeration
typedef Iterator const_iterator;
/** \brief enumerate all entries
* \return an unspecified type that have .begin() and .end() methods
* and is usable with range-based for.
* Every entry in the range matches \p entrySelector.
* \return a range where every entry matches \p entrySelector
*
* Example:
* \code
@@ -205,13 +201,11 @@ public: // enumeration
* \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<const_iterator>
Range
fullEnumerate(const EntrySelector& entrySelector = AnyEntry()) const;
/** \brief enumerate all entries under a prefix
* \return an unspecified type that have .begin() and .end() methods
* and is usable with range-based for.
* Every entry in the range has a name that starts with \p prefix,
* \return a range where every entry has a name that starts with \p prefix,
* and matches \p entrySubTreeSelector.
*
* Example:
@@ -227,7 +221,7 @@ public: // enumeration
* \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<const_iterator>
Range
partialEnumerate(const Name& prefix,
const EntrySubTreeSelector& entrySubTreeSelector = AnyEntrySubTree()) const;