CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

cmsutils::bqueue< T > Class Template Reference

#include <bqueue.h>

List of all members.

Public Types

typedef _bqueue_itr< value_typeconst_iterator
typedef _bqueue_item< value_typeitem
typedef boost::intrusive_ptr
< _bqueue_item< value_type > > 
itemptr
typedef _bqueue_itr< value_typeiterator
typedef unsigned short int size_type
typedef T value_type

Public Member Functions

const Tback () const
const_iterator begin () const
 bqueue (bqueue< T > &&cp) noexcept
 bqueue ()
 bqueue (const bqueue< T > &cp)
void clear ()
template<typename... Args>
void emplace_back (Args &&...args)
bool empty () const
const_iterator end () const
bqueue< Tfork () const
const Tfront () const
void join (bqueue< T > &other)
bqueueoperator= (bqueue< T > &&cp) noexcept
const Toperator[] (size_type i) const
void pop_back ()
void push_back (const T &val)
void push_back (T &&val)
const_iterator rbegin () const
const_iterator rend () const
bool shared ()
size_type size () const
void swap (bqueue< T > &cp)
 ~bqueue ()

Private Attributes

itemptr m_head
size_type m_size
itemptr m_tail

Detailed Description

template<class T>
class cmsutils::bqueue< T >

Definition at line 95 of file bqueue.h.


Member Typedef Documentation

template<class T>
typedef _bqueue_itr<value_type> cmsutils::bqueue< T >::const_iterator

Definition at line 102 of file bqueue.h.

template<class T>
typedef _bqueue_item<value_type> cmsutils::bqueue< T >::item

Definition at line 99 of file bqueue.h.

template<class T>
typedef boost::intrusive_ptr< _bqueue_item<value_type> > cmsutils::bqueue< T >::itemptr

Definition at line 100 of file bqueue.h.

template<class T>
typedef _bqueue_itr<value_type> cmsutils::bqueue< T >::iterator

Definition at line 101 of file bqueue.h.

template<class T>
typedef unsigned short int cmsutils::bqueue< T >::size_type

Definition at line 98 of file bqueue.h.

template<class T>
typedef T cmsutils::bqueue< T >::value_type

Definition at line 97 of file bqueue.h.


Constructor & Destructor Documentation

template<class T>
cmsutils::bqueue< T >::bqueue ( ) [inline]

Definition at line 104 of file bqueue.h.

: m_size(0),  m_head(), m_tail() { }
template<class T>
cmsutils::bqueue< T >::~bqueue ( ) [inline]

Definition at line 105 of file bqueue.h.

{ }
template<class T>
cmsutils::bqueue< T >::bqueue ( const bqueue< T > &  cp) [inline]

Definition at line 107 of file bqueue.h.

: m_size(cp.m_size), m_head(cp.m_head), m_tail(cp.m_tail) { }
template<class T>
cmsutils::bqueue< T >::bqueue ( bqueue< T > &&  cp) [inline]

Definition at line 110 of file bqueue.h.

                                    : 
    m_size(cp.m_size),
      m_head(std::move(cp.m_head)), m_tail(std::move(cp.m_tail)) {cp.m_size=0; }

Member Function Documentation

template<class T>
const T& cmsutils::bqueue< T >::back ( ) const [inline]
template<class T>
const_iterator cmsutils::bqueue< T >::begin ( void  ) const [inline]

Definition at line 166 of file bqueue.h.

Referenced by TempTrajectory::TempTrajectory().

{ return m_tail.get(); }
template<class T>
void cmsutils::bqueue< T >::clear ( void  ) [inline]

Definition at line 202 of file bqueue.h.

Referenced by TempTrajectory::join(), and cmsutils::bqueue< TrajectoryMeasurement >::join().

                 { 
      m_head = m_tail = nullptr;
      m_size = 0;
    }
template<class T>
template<typename... Args>
void cmsutils::bqueue< T >::emplace_back ( Args &&...  args) [inline]

Definition at line 147 of file bqueue.h.

Referenced by TempTrajectory::emplace().

                                      {
      m_tail = itemptr(new item(this->m_tail, std::forward<Args>(args)...)); 
      if ((++m_size) == 1) { m_head = m_tail; };
    }
template<class T>
bool cmsutils::bqueue< T >::empty ( void  ) const [inline]

Definition at line 169 of file bqueue.h.

Referenced by TempTrajectory::empty().

{ return m_size == 0; }
template<class T>
const_iterator cmsutils::bqueue< T >::end ( void  ) const [inline]

Definition at line 167 of file bqueue.h.

Referenced by TempTrajectory::TempTrajectory().

{ return nullptr; }
template<class T>
bqueue<T> cmsutils::bqueue< T >::fork ( ) const [inline]

Definition at line 129 of file bqueue.h.

                           {
      return *this;
    }
template<class T>
const T& cmsutils::bqueue< T >::front ( ) const [inline]
template<class T>
void cmsutils::bqueue< T >::join ( bqueue< T > &  other) [inline]

Definition at line 187 of file bqueue.h.

Referenced by TempTrajectory::join().

                                {
      assert(!other.shared());
      using std::swap;
      if (m_size == 0) {
        swap(m_head,other.m_head);
        swap(m_tail,other.m_tail);
        swap(m_size,other.m_size);
      } else {
        other.m_head->back = this->m_tail;
        m_tail = other.m_tail;
        m_size += other.m_size;
        other.clear();
      }
    }
template<class T>
bqueue& cmsutils::bqueue< T >::operator= ( bqueue< T > &&  cp) [inline]

Definition at line 114 of file bqueue.h.

                                                {
      using std::swap;
      swap(m_size,cp.m_size);
      swap(m_head,cp.m_head); 
      swap(m_tail,cp.m_tail);
      return *this;
    }
template<class T>
const T& cmsutils::bqueue< T >::operator[] ( size_type  i) const [inline]

Definition at line 170 of file bqueue.h.

                                            {
      int idx = m_size - i - 1;
      const_iterator it = rbegin();
      while (idx-- > 0) --it;
      return *it;
    }
template<class T>
void cmsutils::bqueue< T >::pop_back ( ) [inline]

Definition at line 152 of file bqueue.h.

Referenced by TempTrajectory::pop().

                    {
      assert(m_size > 0);
      --m_size;
      m_tail = m_tail->back;
      if (m_size == 0) m_head = nullptr; 
    }
template<class T>
void cmsutils::bqueue< T >::push_back ( const T val) [inline]

Definition at line 134 of file bqueue.h.

Referenced by TempTrajectory::push().

                                 {
      m_tail = itemptr(new item(this->m_tail, val)); 
      if ((++m_size) == 1) { m_head = m_tail; };
    }
template<class T>
void cmsutils::bqueue< T >::push_back ( T &&  val) [inline]

Definition at line 140 of file bqueue.h.

                            {
      m_tail = itemptr(new item(this->m_tail, std::forward<T>(val))); 
      if ((++m_size) == 1) { m_head = m_tail; };
    }
template<class T>
const_iterator cmsutils::bqueue< T >::rbegin ( ) const [inline]
template<class T>
const_iterator cmsutils::bqueue< T >::rend ( ) const [inline]
template<class T>
bool cmsutils::bqueue< T >::shared ( ) [inline]

Definition at line 177 of file bqueue.h.

Referenced by TempTrajectory::join(), and cmsutils::bqueue< TrajectoryMeasurement >::join().

                  { 
      // size = 0: never shared
      // size = 1: shared if head->refCount > 2 (m_head and m_tail)
      // size > 1: shared if head->refCount > 2 (m_head and second_hit->back)
      return (m_size > 0) && (m_head->refCount > 2);
    }
template<class T>
size_type cmsutils::bqueue< T >::size ( void  ) const [inline]
template<class T>
void cmsutils::bqueue< T >::swap ( bqueue< T > &  cp) [inline]

Member Data Documentation

template<class T>
itemptr cmsutils::bqueue< T >::m_head [private]
template<class T>
size_type cmsutils::bqueue< T >::m_size [private]
template<class T>
itemptr cmsutils::bqueue< T >::m_tail [private]