CMS 3D CMS Logo

StringMap Class Reference

#include <DataFormats/PatCandidates/interface/StringMap.h>

List of all members.

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 (int32_t number) const
const_iterator find (const std::string &string) const
const std::string & 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
int32_t 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
size_t size () const
void sort ()

Private Attributes

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

Classes

class  MatchByNumber
class  MatchByString


Detailed Description

Definition at line 8 of file StringMap.h.


Member Typedef Documentation

typedef vector_type::const_iterator StringMap::const_iterator

Definition at line 12 of file StringMap.h.

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

Definition at line 10 of file StringMap.h.

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

Definition at line 11 of file StringMap.h.


Member Function Documentation

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

Definition at line 3 of file StringMap.cc.

References entries_.

00003                                                           {
00004     entries_.push_back(value_type(string,value));
00005 }

const_iterator StringMap::begin (  )  const [inline]

Definition at line 31 of file StringMap.h.

References entries_.

00031 { return entries_.begin(); }

void StringMap::clear ( void   ) 

Definition at line 11 of file StringMap.cc.

References entries_.

00011                       {
00012     entries_.clear();
00013 }

const_iterator StringMap::end (  )  const [inline]

Definition at line 32 of file StringMap.h.

References entries_.

Referenced by find(), and operator[]().

00032 { return entries_.end(); }

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

Definition at line 31 of file StringMap.cc.

References entries_.

00031                                                             {
00032     return std::find_if(entries_.begin(), entries_.end(), MatchByNumber(number)); 
00033 }

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

Definition at line 26 of file StringMap.cc.

References end(), entries_, and edm::match().

Referenced by operator[]().

00026                                                                      {
00027     vector_type::const_iterator match =  std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
00028     return (match->first == string ? match : end());
00029 }

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 20 of file StringMap.cc.

References end(), find(), and edm::match().

00020                                                             {
00021     static std::string empty_;
00022     vector_type::const_iterator match = find(number);
00023     return (match == end() ? empty_ : match->first);
00024 }

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 15 of file StringMap.cc.

References end(), entries_, and edm::match().

00015                                                            {
00016     vector_type::const_iterator match =  std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
00017     return (match == end() ? -1 : match->second);
00018 }

size_t StringMap::size ( void   )  const [inline]

Definition at line 34 of file StringMap.h.

References entries_.

00034 { return entries_.size(); }

void StringMap::sort (  ) 

Definition at line 7 of file StringMap.cc.

References entries_, and python::multivaluedict::sort().

00007                      {
00008     std::sort(entries_.begin(), entries_.end());
00009 }


Member Data Documentation

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

Definition at line 36 of file StringMap.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:56 2009 for CMSSW by  doxygen 1.5.4