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

◆ const_iterator

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

Definition at line 64 of file SmallWORMDict.h.

Constructor & Destructor Documentation

◆ SmallWORMDict() [1/2]

cond::SmallWORMDict::SmallWORMDict ( )

Definition at line 9 of file SmallWORMDict.cc.

9 {}

◆ ~SmallWORMDict()

cond::SmallWORMDict::~SmallWORMDict ( )

Definition at line 10 of file SmallWORMDict.cc.

10 {}

◆ SmallWORMDict() [2/2]

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

Definition at line 12 of file SmallWORMDict.cc.

References a, and b.

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
std::vector< char > m_data
Definition: SmallWORMDict.h:94
const_iterator begin() const
Definition: SmallWORMDict.h:66
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119

Member Function Documentation

◆ begin()

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

Definition at line 66 of file SmallWORMDict.h.

References IterHelp.

Referenced by find().

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

◆ end()

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

Definition at line 70 of file SmallWORMDict.h.

References IterHelp, and size().

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

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

◆ find() [1/2]

SmallWORMDict::const_iterator cond::SmallWORMDict::find ( std::string const &  s) const

Definition at line 41 of file SmallWORMDict.cc.

References begin(), end(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, and alignCSCRings::s.

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
SOAFrame< float > Frame
const_iterator begin() const
Definition: SmallWORMDict.h:66

◆ find() [2/2]

SmallWORMDict::const_iterator cond::SmallWORMDict::find ( char const *  s) const

Definition at line 46 of file SmallWORMDict.cc.

References begin(), end(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, and alignCSCRings::s.

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
SOAFrame< float > Frame
const_iterator begin() const
Definition: SmallWORMDict.h:66

◆ index() [1/2]

size_t cond::SmallWORMDict::index ( std::string const &  s) const

Definition at line 37 of file SmallWORMDict.cc.

References find(), and alignCSCRings::s.

Referenced by BeautifulSoup.PageElement::insert().

37 { return (*find(s)).ind; }
const_iterator find(std::string const &s) const

◆ index() [2/2]

size_t cond::SmallWORMDict::index ( char const *  s) const

Definition at line 39 of file SmallWORMDict.cc.

References find(), and alignCSCRings::s.

Referenced by BeautifulSoup.PageElement::insert().

39 { return (*find(s)).ind; }
const_iterator find(std::string const &s) const

◆ operator[]()

Frame cond::SmallWORMDict::operator[] ( int  i) const
inline

Definition at line 74 of file SmallWORMDict.h.

References mps_fire::i, dqmdumpme::k, m_data, and m_index.

74  {
75  int k = (0 == i) ? 0 : m_index[i - 1];
76  return Frame(&m_data[k], m_index[i] - k, i);
77  }
SOAFrame< float > Frame
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
std::vector< char > m_data
Definition: SmallWORMDict.h:94

◆ serialize()

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

◆ size()

size_t cond::SmallWORMDict::size ( void  ) const

Definition at line 51 of file SmallWORMDict.cc.

References m_index.

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

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

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 97 of file SmallWORMDict.h.

◆ cond::serialization::access

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

Definition at line 97 of file SmallWORMDict.h.

◆ IterHelp

friend struct IterHelp
friend

Definition at line 62 of file SmallWORMDict.h.

Referenced by begin(), and end().

◆ test::SmallWORMDict::test

int test::SmallWORMDict::test ( )
friend

Member Data Documentation

◆ m_data

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

Definition at line 94 of file SmallWORMDict.h.

Referenced by cond::SmallWORMDict::IterHelp::operator()(), and operator[]().

◆ m_index

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

Definition at line 95 of file SmallWORMDict.h.

Referenced by cond::SmallWORMDict::IterHelp::operator()(), operator[](), and size().