Helper functions for std::map.
More...
#include "NAGASH/MapTool.h"
|
| MapTool (std::shared_ptr< MSGTool > MSG) |
| Constructor.
|
|
unsigned int | EditDistance (const std::string &s1, const std::string &s2) const |
| Calculate the edit distance between two strings.
|
|
unsigned int | EditDistance (const TString &s1, const TString &s2) const |
| Calculate the edit distance between two strings.
|
|
template<typename T > |
std::map< std::string, T >::iterator | FindMostSimilar (std::map< std::string, T > &mymap, const std::string &key) |
| Find value to the most similar key in a map.
|
|
template<typename T > |
std::map< TString, T >::iterator | FindMostSimilar (std::map< TString, T > &mymap, const TString &key) |
| Find value to the most similar key in a map.
|
|
template<typename T1 , typename T2 > |
std::vector< T1 > | GetListOfKeys (const std::map< T1, T2 > &inputmap) const |
| Get the vector of keys in a map.
|
|
template<typename T1 , typename T2 > |
std::vector< T2 > | GetListOfValues (const std::map< T1, T2 > &inputmap) const |
| Get the vector of values in a map.
|
|
Helper functions for std::map.
Definition at line 16 of file MapTool.h.
◆ MapTool()
NAGASH::MapTool::MapTool |
( |
std::shared_ptr< MSGTool > |
MSG | ) |
|
|
inline |
◆ EditDistance() [1/2]
unsigned int MapTool::EditDistance |
( |
const std::string & |
s1, |
|
|
const std::string & |
s2 |
|
) |
| const |
Calculate the edit distance between two strings.
Definition at line 29 of file MapTool.cxx.
◆ EditDistance() [2/2]
unsigned int MapTool::EditDistance |
( |
const TString & |
s1, |
|
|
const TString & |
s2 |
|
) |
| const |
Calculate the edit distance between two strings.
Definition at line 11 of file MapTool.cxx.
◆ FindMostSimilar() [1/2]
template<typename T >
std::map< std::string, T >::iterator NAGASH::MapTool::FindMostSimilar |
( |
std::map< std::string, T > & |
mymap, |
|
|
const std::string & |
key |
|
) |
| |
|
inline |
Find value to the most similar key in a map.
- Template Parameters
-
T | type of the value of the map. |
- Parameters
-
mymap | the input map. |
key | the key to be searched. |
- Returns
- if the key exists in the map, return the iterator pointing to the key, otherwise return value to the most similar key in the map. The similarity is calculated by the EditDistance function.
Definition at line 91 of file MapTool.h.
◆ FindMostSimilar() [2/2]
template<typename T >
std::map< TString, T >::iterator NAGASH::MapTool::FindMostSimilar |
( |
std::map< TString, T > & |
mymap, |
|
|
const TString & |
key |
|
) |
| |
|
inline |
Find value to the most similar key in a map.
- Template Parameters
-
T | type of the value of the map. |
- Parameters
-
mymap | the input map. |
key | the key to be searched. |
- Returns
- if the key exists in the map, return the iterator pointing to the key, otherwise return value to the most similar key in the map. The similarity is calculated by the EditDistance function.
Definition at line 43 of file MapTool.h.
◆ GetListOfKeys()
template<typename T1 , typename T2 >
std::vector< T1 > NAGASH::MapTool::GetListOfKeys |
( |
const std::map< T1, T2 > & |
inputmap | ) |
const |
|
inline |
Get the vector of keys in a map.
Definition at line 135 of file MapTool.h.
◆ GetListOfValues()
template<typename T1 , typename T2 >
std::vector< T2 > NAGASH::MapTool::GetListOfValues |
( |
const std::map< T1, T2 > & |
inputmap | ) |
const |
|
inline |
Get the vector of values in a map.
Definition at line 145 of file MapTool.h.
The documentation for this class was generated from the following files: