CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
StringMap Class Reference

#include <StringMap.h>

Classes

class  MatchByNumber
 
class  MatchByString
 

Public Types

typedef vector_type::const_iterator const_iterator
 
typedef std::pair< std::string, int32_t > value_type
 
typedef std::vector< value_typevector_type
 

Public Member Functions

void add (const std::string &string, int32_t value)
 
const_iterator begin () const
 
void clear ()
 
const_iterator end () const
 
const_iterator find (const std::string &string) const
 
const_iterator find (int32_t number) const
 
int32_t operator[] (const std::string &string) const
 
const std::string & operator[] (int32_t number) const
 
size_t size () const
 
void sort ()
 

Private Attributes

std::vector< std::pair< std::string, int32_t > > entries_
 

Detailed Description

Definition at line 8 of file StringMap.h.

Member Typedef Documentation

◆ const_iterator

typedef vector_type::const_iterator StringMap::const_iterator

Definition at line 12 of file StringMap.h.

◆ value_type

typedef std::pair<std::string, int32_t> StringMap::value_type

Definition at line 10 of file StringMap.h.

◆ vector_type

typedef std::vector<value_type> StringMap::vector_type

Definition at line 11 of file StringMap.h.

Member Function Documentation

◆ add()

void StringMap::add ( const std::string &  string,
int32_t  value 
)

Definition at line 3 of file StringMap.cc.

3 { entries_.push_back(value_type(string, value)); }

References entries_.

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

◆ begin()

const_iterator StringMap::begin ( void  ) const
inline

Definition at line 31 of file StringMap.h.

31 { return entries_.begin(); }

References entries_.

Referenced by edm::ParameterSetConverter::convertParameterSets().

◆ clear()

void StringMap::clear ( void  )

Definition at line 7 of file StringMap.cc.

7 { entries_.clear(); }

References entries_.

Referenced by BeautifulSoup.Tag::setString().

◆ end()

const_iterator StringMap::end ( void  ) const
inline

◆ find() [1/2]

StringMap::const_iterator StringMap::find ( const std::string &  string) const

Definition at line 20 of file StringMap.cc.

20  {
21  vector_type::const_iterator match = std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
22  return (match->first == string ? match : end());
23 }

References end(), entries_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, match(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by BeautifulSoup.Tag::__getattr__(), BeautifulSoup.Tag::firstText(), and operator[]().

◆ find() [2/2]

StringMap::const_iterator StringMap::find ( int32_t  number) const

Definition at line 25 of file StringMap.cc.

25  {
26  return std::find_if(entries_.begin(), entries_.end(), MatchByNumber(number));
27 }

References entries_, and contentValuesFiles::number.

Referenced by BeautifulSoup.Tag::__getattr__(), and BeautifulSoup.Tag::firstText().

◆ operator[]() [1/2]

int32_t StringMap::operator[] ( const std::string &  string) const

return associated number, or -1 if no one is found in case the association is not unque, the choice of the returned value is undetermined note: works only after it's sorted

Definition at line 9 of file StringMap.cc.

9  {
10  vector_type::const_iterator match = std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
11  return (match == end() ? -1 : match->second);
12 }

References end(), entries_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, match(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ operator[]() [2/2]

const std::string & StringMap::operator[] ( int32_t  number) const

return associated string, or "" if none is there in case the association is not unque, the choice of the returned value is undetermined note: works only after it's sorted

Definition at line 14 of file StringMap.cc.

14  {
15  static const std::string empty_;
16  vector_type::const_iterator match = find(number);
17  return (match == end() ? empty_ : match->first);
18 }

References end(), find(), match(), contentValuesFiles::number, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ size()

size_t StringMap::size ( void  ) const
inline

Definition at line 34 of file StringMap.h.

34 { return entries_.size(); }

References entries_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

◆ sort()

void StringMap::sort ( )

Definition at line 5 of file StringMap.cc.

5 { std::sort(entries_.begin(), entries_.end()); }

References entries_, and jetUpdater_cfi::sort.

Member Data Documentation

◆ entries_

std::vector<std::pair<std::string, int32_t> > StringMap::entries_
private

Definition at line 54 of file StringMap.h.

Referenced by add(), begin(), clear(), end(), find(), operator[](), size(), and sort().

contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
StringMap::end
const_iterator end() const
Definition: StringMap.h:32
value
Definition: value.py:1
StringMap::entries_
std::vector< std::pair< std::string, int32_t > > entries_
Definition: StringMap.h:54
StringMap::find
const_iterator find(const std::string &string) const
Definition: StringMap.cc:20
StringMap::value_type
std::pair< std::string, int32_t > value_type
Definition: StringMap.h:10