tools: Fixing bugs in nfd-status
Also in this commit: implementing const_reverse_iterator in FaceTable.
It also would be good to have reverse iterator in Fib, but not strictly
necessary.
Change-Id: Ie9cf849b718f5db76db2957b4452790f9ae68fd3
Refs: #1378
diff --git a/daemon/core/map-value-iterator.hpp b/daemon/core/map-value-iterator.hpp
index c8d3df7..6d80887 100644
--- a/daemon/core/map-value-iterator.hpp
+++ b/daemon/core/map-value-iterator.hpp
@@ -17,13 +17,15 @@
*/
template<typename Map>
class MapValueIterator
- : public boost::transform_iterator<function<const typename Map::mapped_type&(const typename Map::value_type&)>,
- typename Map::const_iterator>
+ : public boost::transform_iterator<
+ function<const typename Map::mapped_type&(const typename Map::value_type&)>,
+ typename Map::const_iterator>
{
public:
explicit
MapValueIterator(typename Map::const_iterator it)
- : boost::transform_iterator<function<const typename Map::mapped_type&(const typename Map::value_type&)>,
+ : boost::transform_iterator<
+ function<const typename Map::mapped_type&(const typename Map::value_type&)>,
typename Map::const_iterator>(it, &takeSecond)
{
}
@@ -36,6 +38,32 @@
}
};
+/** \class MapValueReverseIterator
+ * \brief ReverseIterator to iterator over map values
+ */
+template<typename Map>
+class MapValueReverseIterator
+ : public boost::transform_iterator<
+ function<const typename Map::mapped_type&(const typename Map::value_type&)>,
+ typename Map::const_reverse_iterator>
+{
+public:
+ explicit
+ MapValueReverseIterator(typename Map::const_reverse_iterator it)
+ : boost::transform_iterator<
+ function<const typename Map::mapped_type&(const typename Map::value_type&)>,
+ typename Map::const_reverse_iterator>(it, &takeSecond)
+ {
+ }
+
+private:
+ static const typename Map::mapped_type&
+ takeSecond(const typename Map::value_type& pair)
+ {
+ return pair.second;
+ }
+};
+
} // namespace nfd
#endif // NFD_CORE_MAP_VALUE_ITERATOR_H