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 67 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(), popcon2dropbox::copy(), end(), mps_fire::i, m_data, m_index, and AlCaHLTBitMon_ParallelJobs::p.

12  :
13  m_data(std::accumulate(idict.begin(), idict.end(), 0,
14  [](int a, std::string b) { return a + b.size(); })),
15  m_index(idict.size(),1) {
16 
17  // sort (use index)
18  m_index[0]=0; std::partial_sum(m_index.begin(),m_index.end(),m_index.begin());
19  std::sort(m_index.begin(), m_index.end(),
20  [&idict](unsigned int a, unsigned int b) { return std::less<std::string>()(idict[a], idict[b]); });
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 
30  }
const_iterator end() const
Definition: SmallWORMDict.h:75
std::vector< unsigned int > m_index
const_iterator begin() const
Definition: SmallWORMDict.h:70
std::vector< char > m_data
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

Member Function Documentation

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

Definition at line 70 of file SmallWORMDict.h.

Referenced by find(), and SmallWORMDict().

70  {
71  return boost::make_transform_iterator(boost::counting_iterator<int>(0),
72  IterHelp(*this));
73  }
friend struct IterHelp
Definition: SmallWORMDict.h:65
const_iterator cond::SmallWORMDict::end ( void  ) const
inline

Definition at line 75 of file SmallWORMDict.h.

References findQualityFiles::size.

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

75  {
76  return boost::make_transform_iterator(boost::counting_iterator<int>(size()),
77  IterHelp(*this));
78  }
friend struct IterHelp
Definition: SmallWORMDict.h:65
size_t size() const
SmallWORMDict::const_iterator cond::SmallWORMDict::find ( std::string const &  s) const

Definition at line 48 of file SmallWORMDict.cc.

References begin(), and end().

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

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

Definition at line 54 of file SmallWORMDict.cc.

References begin(), and end().

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

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

Definition at line 40 of file SmallWORMDict.cc.

References find().

Referenced by BeautifulSoup.PageElement::insert().

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

Definition at line 44 of file SmallWORMDict.cc.

References find().

Referenced by BeautifulSoup.PageElement::insert().

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

Definition at line 80 of file SmallWORMDict.h.

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

80  {
81  int k = (0==i) ? 0 : m_index[i-1];
82  return Frame(&m_data[k], m_index[i]-k, i);
83  }
std::vector< unsigned int > m_index
std::vector< char > m_data
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 61 of file SmallWORMDict.cc.

References m_index.

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

61 { return m_index.size(); }
std::vector< unsigned int > m_index

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 103 of file SmallWORMDict.h.

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

Definition at line 103 of file SmallWORMDict.h.

friend struct IterHelp
friend

Definition at line 65 of file SmallWORMDict.h.

int test::SmallWORMDict::test ( )
friend

Member Data Documentation

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

Definition at line 100 of file SmallWORMDict.h.

Referenced by SmallWORMDict().

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

Definition at line 101 of file SmallWORMDict.h.

Referenced by size(), and SmallWORMDict().