CMS 3D CMS Logo

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
 
int test::SmallWORMDict::test ()
 

Detailed Description

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

Definition at line 25 of file SmallWORMDict.h.

Member Typedef Documentation

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

Definition at line 64 of file SmallWORMDict.h.

Constructor & Destructor Documentation

cond::SmallWORMDict::SmallWORMDict ( )

Definition at line 9 of file SmallWORMDict.cc.

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

Definition at line 10 of file SmallWORMDict.cc.

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

Definition at line 12 of file SmallWORMDict.cc.

References a, b, begin(), filterCSVwithJSON::copy, end(), mps_fire::i, dqmiolumiharvest::j, m_data, m_index, and AlCaHLTBitMon_ParallelJobs::p.

13  : m_data(std::accumulate(idict.begin(), idict.end(), 0, [](int a, std::string b) { return a + b.size(); })),
14  m_index(idict.size(), 1) {
15  // sort (use index)
16  m_index[0] = 0;
17  std::partial_sum(m_index.begin(), m_index.end(), m_index.begin());
18  std::sort(m_index.begin(), m_index.end(), [&idict](unsigned int a, unsigned int b) {
19  return std::less<std::string>()(idict[a], idict[b]);
20  });
21 
22  //copy
23  std::vector<char>::iterator p = m_data.begin();
24  for (size_t j = 0; j < m_index.size(); j++) {
25  size_t i = m_index[j];
26  p = std::copy(idict[i].begin(), idict[i].end(), p);
27  m_index[j] = p - m_data.begin();
28  }
29  }
const_iterator end() const
Definition: SmallWORMDict.h:70
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
const_iterator begin() const
Definition: SmallWORMDict.h:66
std::vector< char > m_data
Definition: SmallWORMDict.h:94
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119

Member Function Documentation

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

Definition at line 66 of file SmallWORMDict.h.

Referenced by find(), and SmallWORMDict().

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

Definition at line 70 of file SmallWORMDict.h.

References findQualityFiles::size.

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

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

Definition at line 41 of file SmallWORMDict.cc.

References begin(), and end().

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

41  {
42  Frame sp(&s[0], s.size(), 0);
43  return std::lower_bound(begin(), end(), sp, LessFrame());
44  }
const_iterator end() const
Definition: SmallWORMDict.h:70
const_iterator begin() const
Definition: SmallWORMDict.h:66
SmallWORMDict::const_iterator cond::SmallWORMDict::find ( char const *  s) const

Definition at line 46 of file SmallWORMDict.cc.

References begin(), and end().

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

46  {
47  Frame sp(s, ::strlen(s), 0);
48  return std::lower_bound(begin(), end(), sp, LessFrame());
49  }
const_iterator end() const
Definition: SmallWORMDict.h:70
const_iterator begin() const
Definition: SmallWORMDict.h:66
size_t cond::SmallWORMDict::index ( std::string const &  s) const

Definition at line 37 of file SmallWORMDict.cc.

References find().

Referenced by BeautifulSoup.PageElement::insert().

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

Definition at line 39 of file SmallWORMDict.cc.

References find().

Referenced by BeautifulSoup.PageElement::insert().

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

Definition at line 74 of file SmallWORMDict.h.

References spr::find(), mps_fire::i, dqmdumpme::k, alignCSCRings::s, findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

74  {
75  int k = (0 == i) ? 0 : m_index[i - 1];
76  return Frame(&m_data[k], m_index[i] - k, i);
77  }
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
std::vector< char > m_data
Definition: SmallWORMDict.h:94
template<class Archive >
void cond::SmallWORMDict::serialize ( Archive &  ar,
const unsigned int  version 
)
private
size_t cond::SmallWORMDict::size ( void  ) const

Definition at line 51 of file SmallWORMDict.cc.

References m_index.

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

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

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 97 of file SmallWORMDict.h.

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

Definition at line 97 of file SmallWORMDict.h.

friend struct IterHelp
friend

Definition at line 62 of file SmallWORMDict.h.

int test::SmallWORMDict::test ( )
friend

Member Data Documentation

std::vector<char> cond::SmallWORMDict::m_data
private

Definition at line 94 of file SmallWORMDict.h.

Referenced by SmallWORMDict().

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

Definition at line 95 of file SmallWORMDict.h.

Referenced by size(), and SmallWORMDict().