winss
map_value_iterator.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2017 Morgan Stanley
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIB_WINSS_MAP_VALUE_ITERATOR_HPP_
18 #define LIB_WINSS_MAP_VALUE_ITERATOR_HPP_
19 
20 #include <map>
21 
22 namespace winss {
29 template<typename Key, typename Value>
30 using Map = std::map<Key, Value>;
31 
38 template<typename Key, typename Value>
40 
47 template<typename Key, typename Value>
48 class MapKeyIterator : public MapIterator<Key, Value> {
49  public:
53  MapKeyIterator() : MapIterator<Key, Value>() {}
54 
61  MapIterator<Key, Value>(it) {}
62 
68  Key* operator->() {
69  return (Key* const)&(MapIterator<Key, Value>::operator->()->first);
70  }
71 
77  Key operator*() {
79  }
80 };
81 
88 template<typename Key, typename Value>
89 class MapValueIterator : public MapIterator<Key, Value> {
90  public:
94  MapValueIterator() : MapIterator<Key, Value>() {}
95 
102  MapIterator<Key, Value>(it) {}
103 
109  Value* operator->() {
110  return (Value* const)&(MapIterator<Key, Value>::operator->()->second);
111  }
112 
118  Value operator*() {
119  return MapIterator<Key, Value>::operator*().second;
120  }
121 };
122 } // namespace winss
123 
124 #endif // LIB_WINSS_MAP_VALUE_ITERATOR_HPP_
An iterator for keys of a map.
Definition: map_value_iterator.hpp:48
Definition: case_ignore.hpp:23
MapValueIterator()
Construct a new map value iterator.
Definition: map_value_iterator.hpp:94
Value operator*()
Get the dereferenced current value.
Definition: map_value_iterator.hpp:118
Value * operator->()
Get a pointer to the current value.
Definition: map_value_iterator.hpp:109
MapValueIterator(MapIterator< Key, Value > it)
Construct a map value iterator using a base iterator.
Definition: map_value_iterator.hpp:101
Key * operator->()
Get a pointer to the current key.
Definition: map_value_iterator.hpp:68
std::map< Key, Value > Map
Use std::map as the map.
Definition: map_value_iterator.hpp:30
typename Map< Key, Value >::iterator MapIterator
Use std::map::iterator as the map iterator.
Definition: map_value_iterator.hpp:39
MapKeyIterator(MapIterator< Key, Value > it)
Construct a map key iterator using a base iterator.
Definition: map_value_iterator.hpp:60
An iterator for values of a map.
Definition: map_value_iterator.hpp:89
MapKeyIterator()
Construct a new map key iterator.
Definition: map_value_iterator.hpp:53
Key operator*()
Get the dereferenced current key.
Definition: map_value_iterator.hpp:77