arsenalgear-cpp
A library containing general purpose C++ utils.
containers.hpp
Go to the documentation of this file.
1 //====================================================
2 // File data
3 //====================================================
11 //====================================================
12 // Preprocessor settings
13 //====================================================
14 #pragma once
15 #ifndef ARSENALGEAR_CONTAINERS_HPP
16 #define ARSENALGEAR_CONTAINERS_HPP
17 
18 //====================================================
19 // Headers
20 //====================================================
21 
22 // STD headers
23 #include <vector>
24 #include <map>
25 
26 namespace agr
27  {
28  //====================================================
29  // Functions
30  //====================================================
31 
32  // extract_map_keys
41  template <typename TK, typename TV>
42  inline std::vector<TK> extract_map_keys( std::map<TK, TV> const& input_map )
43  {
44  std::vector<TK> retval;
45  retval.clear();
46 
47  for ( auto const& element : input_map ) retval.push_back( element.first );
48 
49  return retval;
50  }
51 
52  // extract_map_elem
61  template <typename TK, typename TV>
62  inline std::vector<TV> extract_map_elem( std::map<TK, TV> const& input_map )
63  {
64  std::vector<TV> retval;
65  retval.clear();
66 
67  for ( auto const& element : input_map ) retval.push_back( element.second );
68 
69  return retval;
70  }
71  }
72 
73 #endif
Definition: stream.cpp:22
std::vector< TV > extract_map_elem(std::map< TK, TV > const &input_map)
Function used to extract a vector of elements from a map.
Definition: containers.hpp:62
std::vector< TK > extract_map_keys(std::map< TK, TV > const &input_map)
Function used to extract a vector of keys from a map.
Definition: containers.hpp:42