CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
cond::SmallWORMDict Class Reference

#include <SmallWORMDict.h>

Classes

struct  Frame
 
struct  IterHelp
 

Public Types

typedef
boost::transform_iterator
< IterHelp,
boost::counting_iterator< int > > 
const_iterator
 

Public Member Functions

const_iterator begin () const
 
const_iterator end () const
 
const_iterator find (std::string const &s) const
 
const_iterator find (char const *s) const
 
size_t index (std::string const &s) const
 
size_t index (char const *s) const
 
Frame operator[] (int i) const
 
size_t size () const
 
 SmallWORMDict ()
 
 SmallWORMDict (std::vector< std::string > const &idict)
 
 ~SmallWORMDict ()
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::vector< char > m_data
 
std::vector< unsigned int > m_index
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 
struct IterHelp
 

Detailed Description

A small WORM Dictionary of small words optimized to do a single allocation

Definition at line 23 of file SmallWORMDict.h.

Member Typedef Documentation

typedef boost::transform_iterator<IterHelp,boost::counting_iterator<int> > cond::SmallWORMDict::const_iterator

Definition at line 63 of file SmallWORMDict.h.

Constructor & Destructor Documentation

cond::SmallWORMDict::SmallWORMDict ( )

Definition at line 6 of file SmallWORMDict.cc.

6 {}
cond::SmallWORMDict::~SmallWORMDict ( )

Definition at line 7 of file SmallWORMDict.cc.

7 {}
cond::SmallWORMDict::SmallWORMDict ( std::vector< std::string > const &  idict)
explicit

Definition at line 9 of file SmallWORMDict.cc.

References begin(), filterCSVwithJSON::copy, end(), i, j, m_data, m_index, cppFunctionSkipper::operator, AlCaHLTBitMon_ParallelJobs::p, and python.multivaluedict::sort().

9  :
10  m_data(std::accumulate(idict.begin(),idict.end(),0,
11  boost::bind(std::plus<int>(),_1,boost::bind(&std::string::size,_2)))),
12  m_index(idict.size(),1) {
13 
14  // sort (use index)
15  m_index[0]=0; std::partial_sum(m_index.begin(),m_index.end(),m_index.begin());
16  std::sort(m_index.begin(),m_index.end(),
17  boost::bind(std::less<std::string>(),
18  boost::bind<const std::string&>(&std::vector<std::string>::operator[],boost::ref(idict),_1),
19  boost::bind<const std::string&>(&std::vector<std::string>::operator[],boost::ref(idict),_2)
20  )
21  );
22 
23  //copy
24  std::vector<char>::iterator p= m_data.begin();
25  for (size_t j=0; j<m_index.size(); j++) {
26  size_t i = m_index[j];
27  p=std::copy(idict[i].begin(),idict[i].end(),p);
28  m_index[j]=p-m_data.begin();
29  }
30 
31  }
int i
Definition: DBlmapReader.cc:9
const_iterator end() const
Definition: SmallWORMDict.h:71
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:97
const_iterator begin() const
Definition: SmallWORMDict.h:66
std::vector< char > m_data
Definition: SmallWORMDict.h:96
int j
Definition: DBlmapReader.cc:9
tuple size
Write out results.

Member Function Documentation

const_iterator cond::SmallWORMDict::begin ( void  ) const
inline

Definition at line 66 of file SmallWORMDict.h.

References IterHelp.

Referenced by find(), and SmallWORMDict().

66  {
67  return boost::make_transform_iterator(boost::counting_iterator<int>(0),
68  IterHelp(*this));
69  }
friend struct IterHelp
Definition: SmallWORMDict.h:61
const_iterator cond::SmallWORMDict::end ( void  ) const
inline

Definition at line 71 of file SmallWORMDict.h.

References IterHelp, and size().

Referenced by Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), find(), and SmallWORMDict().

71  {
72  return boost::make_transform_iterator(boost::counting_iterator<int>(size()),
73  IterHelp(*this));
74  }
friend struct IterHelp
Definition: SmallWORMDict.h:61
size_t size() const
SmallWORMDict::const_iterator cond::SmallWORMDict::find ( std::string const &  s) const

Definition at line 49 of file SmallWORMDict.cc.

References begin(), and end().

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

49  {
50  Frame sp(&s[0], s.size(),0);
51  return
52  std::lower_bound(begin(),end(),sp, LessFrame());
53  }
const_iterator end() const
Definition: SmallWORMDict.h:71
const_iterator begin() const
Definition: SmallWORMDict.h:66
SmallWORMDict::const_iterator cond::SmallWORMDict::find ( char const *  s) const

Definition at line 55 of file SmallWORMDict.cc.

References begin(), and end().

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

55  {
56  Frame sp(s, ::strlen(s),0);
57  return
58  std::lower_bound(begin(),end(),sp, LessFrame());
59  }
const_iterator end() const
Definition: SmallWORMDict.h:71
const_iterator begin() const
Definition: SmallWORMDict.h:66
size_t cond::SmallWORMDict::index ( std::string const &  s) const

Definition at line 41 of file SmallWORMDict.cc.

References find().

Referenced by BeautifulSoup.PageElement::_invert().

41  {
42  return (*find(s)).ind;
43  }
const_iterator find(std::string const &s) const
size_t cond::SmallWORMDict::index ( char const *  s) const

Definition at line 45 of file SmallWORMDict.cc.

References find().

Referenced by BeautifulSoup.PageElement::_invert().

45  {
46  return (*find(s)).ind;
47  }
const_iterator find(std::string const &s) const
Frame cond::SmallWORMDict::operator[] ( int  i) const
inline

Definition at line 76 of file SmallWORMDict.h.

References i, gen::k, m_data, and m_index.

76  {
77  int k = (0==i) ? 0 : m_index[i-1];
78  return Frame(&m_data[k], m_index[i]-k, i);
79  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:97
std::vector< char > m_data
Definition: SmallWORMDict.h:96
int k[5][pyjets_maxn]
template<class Archive >
void cond::SmallWORMDict::serialize ( Archive &  ar,
const unsigned int  version 
)
private
size_t cond::SmallWORMDict::size ( void  ) const

Definition at line 62 of file SmallWORMDict.cc.

References m_index.

Referenced by end().

62 { return m_index.size(); }
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:97

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 99 of file SmallWORMDict.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 99 of file SmallWORMDict.h.

friend struct IterHelp
friend

Definition at line 61 of file SmallWORMDict.h.

Referenced by begin(), and end().

Member Data Documentation

std::vector<char> cond::SmallWORMDict::m_data
private
std::vector<unsigned int> cond::SmallWORMDict::m_index
private