blob: c8d3df7dbb507cf6616d9d72c4f092f2757887d6 [file] [log] [blame]
Junxiao Shia4f2be82014-03-02 22:56:41 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NFD_CORE_MAP_VALUE_ITERATOR_H
8#define NFD_CORE_MAP_VALUE_ITERATOR_H
9
10#include "common.hpp"
11#include <boost/iterator/transform_iterator.hpp>
12
13namespace nfd {
14
15/** \class MapValueIterator
16 * \brief ForwardIterator to iterator over map values
17 */
18template<typename Map>
19class MapValueIterator
20 : public boost::transform_iterator<function<const typename Map::mapped_type&(const typename Map::value_type&)>,
21 typename Map::const_iterator>
22{
23public:
24 explicit
25 MapValueIterator(typename Map::const_iterator it)
26 : boost::transform_iterator<function<const typename Map::mapped_type&(const typename Map::value_type&)>,
27 typename Map::const_iterator>(it, &takeSecond)
28 {
29 }
30
31private:
32 static const typename Map::mapped_type&
33 takeSecond(const typename Map::value_type& pair)
34 {
35 return pair.second;
36 }
37};
38
39} // namespace nfd
40
41#endif // NFD_CORE_MAP_VALUE_ITERATOR_H