table: Allow iteration over PIT entries

Change-Id: If48d7f827ccb5df0480cfa27bd2f3db4e3f796fa
Refs: #2339
This commit is contained in:
Alexander Afanasyev committed 2015-01-06 10:50:27 -08:00
1 parent 09fc3d9df8
commit 750fa1cf86
3 files changed
+190

No files matched your search

+22
View File
@@ -26,6 +26,10 @@
#include "pit.hpp"
#include <type_traits>
#include <boost/concept/assert.hpp>
#include <boost/concept_check.hpp>
#include <type_traits>
namespace nfd {
namespace pit {
@@ -36,6 +40,17 @@ static_assert(std::is_move_constructible<DataMatchResult>::value,
} // namespace pit
// http://en.cppreference.com/w/cpp/concept/ForwardIterator
BOOST_CONCEPT_ASSERT((boost::ForwardIterator<Pit::const_iterator>));
// boost::ForwardIterator follows SGI standard http://www.sgi.com/tech/stl/ForwardIterator.html,
// which doesn't require DefaultConstructible
#ifdef HAVE_IS_DEFAULT_CONSTRUCTIBLE
static_assert(std::is_default_constructible<Pit::const_iterator>::value,
"Pit::const_iterator must be default-constructible");
#else
BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<Pit::const_iterator>));
#endif // HAVE_IS_DEFAULT_CONSTRUCTIBLE
Pit::Pit(NameTree& nameTree)
: m_nameTree(nameTree)
, m_nItems(0)
@@ -101,4 +116,11 @@ Pit::erase(shared_ptr<pit::Entry> pitEntry)
--m_nItems;
}
Pit::const_iterator
Pit::begin() const
{
return const_iterator(m_nameTree.fullEnumerate(
[] (const name_tree::Entry& entry) { return entry.hasPitEntries(); }).begin());
}
} // namespace nfd