CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

edm::MapOfVectors< K, T > Class Template Reference

#include <MapOfVectors.h>

List of all members.

Classes

class  Iter

Public Types

typedef Iter const_iterator
typedef std::vector< TData
typedef Data::const_iterator data_iterator
typedef Keys::const_iterator key_iterator
typedef std::vector< K > Keys
typedef Offsets::const_iterator offset_iterator
typedef std::vector< size_typeOffsets
typedef std::pair< K, rangePair
typedef boost::iterator_range
< data_iterator
range
typedef MapOfVectors< K, Tself
typedef unsigned int size_type
typedef std::map< K,
std::vector< T > > 
TheMap

Public Member Functions

const_iterator begin () const
bool empty () const
range emptyRange () const
const_iterator end () const
range find (K const &k) const
key_iterator findKey (K const &k) const
void loadNext (K const &k, std::vector< T > const &v)
 MapOfVectors ()
 MapOfVectors (TheMap const &it)
size_type offset (K const &k) const
MapOfVectorsoperator= (MapOfVectors const &rhs)
size_type size () const
void swap (MapOfVectors &other)

Private Attributes

std::vector< Tm_data
std::vector< K > m_keys
std::vector< size_typem_offsets

Detailed Description

template<typename K, typename T>
class edm::MapOfVectors< K, T >

Definition at line 16 of file MapOfVectors.h.


Member Typedef Documentation

template<typename K, typename T>
typedef Iter edm::MapOfVectors< K, T >::const_iterator

Definition at line 77 of file MapOfVectors.h.

template<typename K, typename T>
typedef std::vector<T> edm::MapOfVectors< K, T >::Data

Definition at line 26 of file MapOfVectors.h.

template<typename K, typename T>
typedef Data::const_iterator edm::MapOfVectors< K, T >::data_iterator

Definition at line 30 of file MapOfVectors.h.

template<typename K, typename T>
typedef Keys::const_iterator edm::MapOfVectors< K, T >::key_iterator

Definition at line 28 of file MapOfVectors.h.

template<typename K, typename T>
typedef std::vector<K> edm::MapOfVectors< K, T >::Keys

Definition at line 24 of file MapOfVectors.h.

template<typename K, typename T>
typedef Offsets::const_iterator edm::MapOfVectors< K, T >::offset_iterator

Definition at line 29 of file MapOfVectors.h.

template<typename K, typename T>
typedef std::vector<size_type> edm::MapOfVectors< K, T >::Offsets

Definition at line 25 of file MapOfVectors.h.

template<typename K, typename T>
typedef std::pair<K , range> edm::MapOfVectors< K, T >::Pair

Definition at line 34 of file MapOfVectors.h.

template<typename K, typename T>
typedef boost::iterator_range<data_iterator> edm::MapOfVectors< K, T >::range

Definition at line 32 of file MapOfVectors.h.

template<typename K, typename T>
typedef MapOfVectors<K,T> edm::MapOfVectors< K, T >::self

Definition at line 19 of file MapOfVectors.h.

template<typename K, typename T>
typedef unsigned int edm::MapOfVectors< K, T >::size_type

Definition at line 22 of file MapOfVectors.h.

template<typename K, typename T>
typedef std::map<K,std::vector<T> > edm::MapOfVectors< K, T >::TheMap

Definition at line 20 of file MapOfVectors.h.


Constructor & Destructor Documentation

template<typename K, typename T>
edm::MapOfVectors< K, T >::MapOfVectors ( ) [inline]

Definition at line 82 of file MapOfVectors.h.

:  m_offsets(1,0) {}
template<typename K, typename T>
edm::MapOfVectors< K, T >::MapOfVectors ( TheMap const &  it) [inline]

Definition at line 84 of file MapOfVectors.h.

                                    {
      m_keys.reserve(it.size());
      m_offsets.reserve(it.size()+1);
      m_offsets.push_back(0);
      size_type tot=0;
      for(typename TheMap::const_iterator p=it.begin(); p!=it.end();++p)
        tot += (*p).second.size();
      m_data.reserve(tot);
      for(typename TheMap::const_iterator p=it.begin(); p!=it.end();++p)
        loadNext((*p).first,(*p).second);

    }

Member Function Documentation

template<typename K, typename T>
const_iterator edm::MapOfVectors< K, T >::begin ( void  ) const [inline]

Definition at line 129 of file MapOfVectors.h.

                                 {
      return const_iterator(m_keys.begin(),m_offsets.begin(),m_data);
    }
template<typename K, typename T>
bool edm::MapOfVectors< K, T >::empty ( ) const [inline]

Definition at line 106 of file MapOfVectors.h.

{ return m_keys.empty();}
template<typename K, typename T>
range edm::MapOfVectors< K, T >::emptyRange ( ) const [inline]

Definition at line 80 of file MapOfVectors.h.

Referenced by edm::MapOfVectors< std::string, AnalysisDescription * >::find().

{ return range(m_data.end(),m_data.end());}
template<typename K, typename T>
const_iterator edm::MapOfVectors< K, T >::end ( void  ) const [inline]

Definition at line 133 of file MapOfVectors.h.

                               {
      return const_iterator(m_keys.end(),m_offsets.begin()+m_keys.size(),m_data);
    }
template<typename K, typename T>
range edm::MapOfVectors< K, T >::find ( K const &  k) const [inline]

Definition at line 120 of file MapOfVectors.h.

                                   {
      key_iterator p = findKey(k);
      if (p==m_keys.end()) return emptyRange();
      size_type loc = p-m_keys.begin();
      data_iterator b = m_data.begin()+m_offsets[loc];
      data_iterator e = m_data.begin()+m_offsets[loc+1];
      return range(b,e);
    }
template<typename K, typename T>
key_iterator edm::MapOfVectors< K, T >::findKey ( K const &  k) const [inline]

Definition at line 108 of file MapOfVectors.h.

Referenced by edm::MapOfVectors< std::string, AnalysisDescription * >::find(), and edm::MapOfVectors< std::string, AnalysisDescription * >::offset().

                                            {
      std::pair<key_iterator,key_iterator> p =
        std::equal_range(m_keys.begin(), m_keys.end(), k);
      return (p.first!=p.second) ? p.first : m_keys.end();
    }
template<typename K, typename T>
void edm::MapOfVectors< K, T >::loadNext ( K const &  k,
std::vector< T > const &  v 
) [inline]
template<typename K, typename T>
size_type edm::MapOfVectors< K, T >::offset ( K const &  k) const [inline]

Definition at line 114 of file MapOfVectors.h.

                                        {
      key_iterator p = findKey(k);
      if (p==m_keys.end()) return m_data.size();
      return m_offsets[p-m_keys.begin()];
    }
template<typename K, typename T>
MapOfVectors& edm::MapOfVectors< K, T >::operator= ( MapOfVectors< K, T > const &  rhs) [inline]

Definition at line 143 of file MapOfVectors.h.

                                                     {
      MapOfVectors temp(rhs);
      this->swap(temp);
      return *this;
    }
template<typename K, typename T>
size_type edm::MapOfVectors< K, T >::size ( void  ) const [inline]

Definition at line 104 of file MapOfVectors.h.

{ return m_keys.size();}
template<typename K, typename T>
void edm::MapOfVectors< K, T >::swap ( MapOfVectors< K, T > &  other) [inline]

Definition at line 137 of file MapOfVectors.h.

Referenced by edm::MapOfVectors< std::string, AnalysisDescription * >::operator=(), and edm::swap().

                                   {
      m_keys.swap(other.m_keys);
      m_offsets.swap(other.m_offsets);
      m_data.swap(other.m_data);
    }

Member Data Documentation

template<typename K, typename T>
std::vector<T> edm::MapOfVectors< K, T >::m_data [private]
template<typename K, typename T>
std::vector<K> edm::MapOfVectors< K, T >::m_keys [private]
template<typename K, typename T>
std::vector<size_type> edm::MapOfVectors< K, T >::m_offsets [private]