CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes | Friends

cond::SmallWORMDict Class Reference

#include <SmallWORMDict.h>

List of all members.

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 (std::vector< std::string > const &idict)
 SmallWORMDict ()
 ~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.

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

Definition at line 7 of file SmallWORMDict.cc.

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

                                                                 :
    m_data(std::accumulate(idict.begin(),idict.end(),0,
                           boost::bind(std::plus<int>(),_1,boost::bind(&std::string::size,_2)))),
    m_index(idict.size(),1) {
    
    // sort (use index)
    m_index[0]=0; std::partial_sum(m_index.begin(),m_index.end(),m_index.begin());
    std::sort(m_index.begin(),m_index.end(), 
              boost::bind(std::less<std::string>(),
                          boost::bind<const std::string&>(&std::vector<std::string>::operator[],boost::ref(idict),_1),
                          boost::bind<const std::string&>(&std::vector<std::string>::operator[],boost::ref(idict),_2)
                          )
              );

    //copy
    std::vector<char>::iterator p= m_data.begin();
    for (size_t j=0; j<m_index.size(); j++) {
      size_t i = m_index[j];
      p=std::copy(idict[i].begin(),idict[i].end(),p);
      m_index[j]=p-m_data.begin();
    }

  }

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

                                 {
      return  boost::make_transform_iterator(boost::counting_iterator<int>(0),
                                             IterHelp(*this));
    }
const_iterator cond::SmallWORMDict::end ( void  ) const [inline]

Definition at line 69 of file SmallWORMDict.h.

References IterHelp, and size().

Referenced by find(), and SmallWORMDict().

                               {
      return  boost::make_transform_iterator(boost::counting_iterator<int>(size()),
                                             IterHelp(*this));
    }
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 index().

                                                                           {
    Frame sp(&s[0], s.size(),0);
    return 
      std::lower_bound(begin(),end(),sp, LessFrame());
  }
SmallWORMDict::const_iterator cond::SmallWORMDict::find ( char const *  s) const

Definition at line 55 of file SmallWORMDict.cc.

References begin(), and end().

                                                                      {
    Frame sp(s, ::strlen(s),0);
    return 
      std::lower_bound(begin(),end(),sp, LessFrame());
  }
size_t cond::SmallWORMDict::index ( char const *  s) const

Definition at line 45 of file SmallWORMDict.cc.

References find().

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

Definition at line 41 of file SmallWORMDict.cc.

References find().

                                                       {
    return (*find(s)).ind;
  }
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.

                                  {
      int k = (0==i) ? 0 : m_index[i-1]; 
      return  Frame(&m_data[k], m_index[i]-k, i);
      } 
size_t cond::SmallWORMDict::size ( void  ) const

Definition at line 62 of file SmallWORMDict.cc.

References m_index.

Referenced by end().

{ return m_index.size(); }

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]