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 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 Attributes

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

Friends

struct IterHelp
 

Detailed Description

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

Definition at line 21 of file SmallWORMDict.h.

Member Typedef Documentation

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

Definition at line 61 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:69
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
const_iterator begin() const
Definition: SmallWORMDict.h:64
std::vector< char > m_data
Definition: SmallWORMDict.h:94
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 64 of file SmallWORMDict.h.

References IterHelp.

Referenced by find(), and SmallWORMDict().

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

Definition at line 69 of file SmallWORMDict.h.

References IterHelp, and size().

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

69  {
70  return boost::make_transform_iterator(boost::counting_iterator<int>(size()),
71  IterHelp(*this));
72  }
friend struct IterHelp
Definition: SmallWORMDict.h:59
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::_invert(), index(), and BeautifulSoup.PageElement::insert().

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:69
const_iterator begin() const
Definition: SmallWORMDict.h:64
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::_invert(), and BeautifulSoup.PageElement::insert().

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:69
const_iterator begin() const
Definition: SmallWORMDict.h:64
size_t cond::SmallWORMDict::index ( std::string const &  s) const

Definition at line 41 of file SmallWORMDict.cc.

References find().

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

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 74 of file SmallWORMDict.h.

References i, gen::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  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
std::vector< char > m_data
Definition: SmallWORMDict.h:94
int k[5][pyjets_maxn]
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:95

Friends And Related Function Documentation

friend struct IterHelp
friend

Definition at line 59 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