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 (char const *s) const
 
const_iterator find (std::string const &s) const
 
size_t index (char const *s) const
 
size_t index (std::string 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.

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  }

References a, and b.

Member Function Documentation

◆ begin()

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

Definition at line 66 of file SmallWORMDict.h.

66  {
67  return boost::make_transform_iterator(boost::counting_iterator<int>(0), IterHelp(*this));
68  }

References IterHelp.

Referenced by find().

◆ end()

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

Definition at line 70 of file SmallWORMDict.h.

70  {
71  return boost::make_transform_iterator(boost::counting_iterator<int>(size()), IterHelp(*this));
72  }

References IterHelp, and size().

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

◆ find() [1/2]

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

Definition at line 46 of file SmallWORMDict.cc.

46  {
47  Frame sp(s, ::strlen(s), 0);
48  return std::lower_bound(begin(), end(), sp, LessFrame());
49  }

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

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

◆ find() [2/2]

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

Definition at line 41 of file SmallWORMDict.cc.

41  {
42  Frame sp(&s[0], s.size(), 0);
43  return std::lower_bound(begin(), end(), sp, LessFrame());
44  }

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

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

◆ index() [1/2]

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

Definition at line 39 of file SmallWORMDict.cc.

39 { return (*find(s)).ind; }

References find(), and alignCSCRings::s.

Referenced by BeautifulSoup.PageElement::insert().

◆ index() [2/2]

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

Definition at line 37 of file SmallWORMDict.cc.

37 { return (*find(s)).ind; }

References find(), and alignCSCRings::s.

Referenced by BeautifulSoup.PageElement::insert().

◆ operator[]()

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

Definition at line 74 of file SmallWORMDict.h.

74  {
75  int k = (0 == i) ? 0 : m_index[i - 1];
76  return Frame(&m_data[k], m_index[i] - k, i);
77  }

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

◆ 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.

51 { return m_index.size(); }

References m_index.

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

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().

cond::SmallWORMDict::m_index
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
mps_fire.i
i
Definition: mps_fire.py:428
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cond::SmallWORMDict::IterHelp
friend struct IterHelp
Definition: SmallWORMDict.h:62
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cond::SmallWORMDict::begin
const_iterator begin() const
Definition: SmallWORMDict.h:66
dqmdumpme.k
k
Definition: dqmdumpme.py:60
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
a
double a
Definition: hdecay.h:119
cond::SmallWORMDict::end
const_iterator end() const
Definition: SmallWORMDict.h:70
cond::SmallWORMDict::m_data
std::vector< char > m_data
Definition: SmallWORMDict.h:94
cond::SmallWORMDict::find
const_iterator find(std::string const &s) const
Definition: SmallWORMDict.cc:41
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
cond::SmallWORMDict::size
size_t size() const
Definition: SmallWORMDict.cc:51