CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
cmsutils::bqueue< T > Class Template Reference

#include <bqueue.h>

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 (const bqueue< T > &cp)
 
 bqueue (bqueue< T > &&cp) noexcept
 
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 > const &)=default
 
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 41 of file bqueue.h.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 129 of file bqueue.h.

◆ item

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

Definition at line 126 of file bqueue.h.

◆ itemptr

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

Definition at line 127 of file bqueue.h.

◆ iterator

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

Definition at line 128 of file bqueue.h.

◆ size_type

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

Definition at line 125 of file bqueue.h.

◆ value_type

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

Definition at line 124 of file bqueue.h.

Constructor & Destructor Documentation

◆ bqueue() [1/3]

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

Definition at line 131 of file bqueue.h.

131 : m_size(0), m_head(), m_tail() {}
itemptr m_head
Definition: bqueue.h:242
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ ~bqueue()

template<class T>
cmsutils::bqueue< T >::~bqueue ( )
inline

Definition at line 132 of file bqueue.h.

132 {}

◆ bqueue() [2/3]

template<class T>
cmsutils::bqueue< T >::bqueue ( const bqueue< T > &  cp)
inline

Definition at line 134 of file bqueue.h.

134 : m_size(cp.m_size), m_head(cp.m_head), m_tail(cp.m_tail) {}
itemptr m_head
Definition: bqueue.h:242
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ bqueue() [3/3]

template<class T>
cmsutils::bqueue< T >::bqueue ( bqueue< T > &&  cp)
inlinenoexcept

Definition at line 137 of file bqueue.h.

137  : m_size(cp.m_size), m_head(std::move(cp.m_head)), m_tail(std::move(cp.m_tail)) {
138  cp.m_size = 0;
139  }
itemptr m_head
Definition: bqueue.h:242
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

◆ back()

template<class T>
const T& cmsutils::bqueue< T >::back ( ) const
inline

◆ begin()

template<class T>
const_iterator cmsutils::bqueue< T >::begin ( void  ) const
inline

Definition at line 199 of file bqueue.h.

199 { return m_tail.get(); }
itemptr m_tail
Definition: bqueue.h:242

◆ clear()

template<class T>
void cmsutils::bqueue< T >::clear ( void  )
inline

Definition at line 235 of file bqueue.h.

Referenced by TempTrajectory::join().

235  {
236  m_head = m_tail = nullptr;
237  m_size = 0;
238  }
itemptr m_head
Definition: bqueue.h:242
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ emplace_back()

template<class T>
template<typename... Args>
void cmsutils::bqueue< T >::emplace_back ( Args &&...  args)
inline

Definition at line 177 of file bqueue.h.

Referenced by TempTrajectory::emplace().

177  {
178  m_tail = itemptr(new item(this->m_tail, std::forward<Args>(args)...));
179  if ((++m_size) == 1) {
180  m_head = m_tail;
181  };
182  }
itemptr m_head
Definition: bqueue.h:242
_bqueue_item< value_type > item
Definition: bqueue.h:126
boost::intrusive_ptr< _bqueue_item< value_type > > itemptr
Definition: bqueue.h:127
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ empty()

template<class T>
bool cmsutils::bqueue< T >::empty ( void  ) const
inline

Definition at line 202 of file bqueue.h.

Referenced by TrajectorySegmentBuilder::addGroup(), and TempTrajectory::empty().

202 { return m_size == 0; }
size_type m_size
Definition: bqueue.h:241

◆ end()

template<class T>
const_iterator cmsutils::bqueue< T >::end ( void  ) const
inline

Definition at line 200 of file bqueue.h.

200 { return nullptr; }

◆ fork()

template<class T>
bqueue<T> cmsutils::bqueue< T >::fork ( ) const
inline

Definition at line 157 of file bqueue.h.

157 { return *this; }

◆ front()

template<class T>
const T& cmsutils::bqueue< T >::front ( ) const
inline

Definition at line 193 of file bqueue.h.

Referenced by TempTrajectory::firstMeasurement().

193 { return m_head->value; }
itemptr m_head
Definition: bqueue.h:242

◆ join()

template<class T>
void cmsutils::bqueue< T >::join ( bqueue< T > &  other)
inline

Definition at line 220 of file bqueue.h.

Referenced by TempTrajectory::join().

220  {
221  assert(!other.shared());
222  using std::swap;
223  if (m_size == 0) {
224  swap(m_head, other.m_head);
225  swap(m_tail, other.m_tail);
226  swap(m_size, other.m_size);
227  } else {
228  other.m_head->back = this->m_tail;
229  m_tail = other.m_tail;
230  m_size += other.m_size;
231  other.clear();
232  }
233  }
void swap(bqueue< T > &cp)
Definition: bqueue.h:150
assert(be >=bs)
itemptr m_head
Definition: bqueue.h:242
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ operator=() [1/2]

template<class T>
bqueue& cmsutils::bqueue< T >::operator= ( bqueue< T > const &  )
default

◆ operator=() [2/2]

template<class T>
bqueue& cmsutils::bqueue< T >::operator= ( bqueue< T > &&  cp)
inlinenoexcept

Definition at line 142 of file bqueue.h.

142  {
143  using std::swap;
144  swap(m_size, cp.m_size);
145  swap(m_head, cp.m_head);
146  swap(m_tail, cp.m_tail);
147  return *this;
148  }
void swap(bqueue< T > &cp)
Definition: bqueue.h:150
itemptr m_head
Definition: bqueue.h:242
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ operator[]()

template<class T>
const T& cmsutils::bqueue< T >::operator[] ( size_type  i) const
inline

Definition at line 203 of file bqueue.h.

203  {
204  int idx = m_size - i - 1;
205  const_iterator it = rbegin();
206  while (idx-- > 0)
207  --it;
208  return *it;
209  }
const_iterator rbegin() const
Definition: bqueue.h:197
_bqueue_itr< value_type > const_iterator
Definition: bqueue.h:129
size_type m_size
Definition: bqueue.h:241

◆ pop_back()

template<class T>
void cmsutils::bqueue< T >::pop_back ( )
inline

Definition at line 184 of file bqueue.h.

Referenced by TempTrajectory::pop().

184  {
185  assert(m_size > 0);
186  --m_size;
187  m_tail = m_tail->back;
188  if (m_size == 0)
189  m_head = nullptr;
190  }
assert(be >=bs)
itemptr m_head
Definition: bqueue.h:242
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ push_back() [1/2]

template<class T>
void cmsutils::bqueue< T >::push_back ( const T val)
inline

Definition at line 160 of file bqueue.h.

Referenced by TempTrajectory::push().

160  {
161  m_tail = itemptr(new item(this->m_tail, val));
162  if ((++m_size) == 1) {
163  m_head = m_tail;
164  };
165  }
itemptr m_head
Definition: bqueue.h:242
_bqueue_item< value_type > item
Definition: bqueue.h:126
boost::intrusive_ptr< _bqueue_item< value_type > > itemptr
Definition: bqueue.h:127
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ push_back() [2/2]

template<class T>
void cmsutils::bqueue< T >::push_back ( T &&  val)
inline

Definition at line 168 of file bqueue.h.

168  {
169  m_tail = itemptr(new item(this->m_tail, std::forward<T>(val)));
170  if ((++m_size) == 1) {
171  m_head = m_tail;
172  };
173  }
itemptr m_head
Definition: bqueue.h:242
_bqueue_item< value_type > item
Definition: bqueue.h:126
boost::intrusive_ptr< _bqueue_item< value_type > > itemptr
Definition: bqueue.h:127
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ rbegin()

template<class T>
const_iterator cmsutils::bqueue< T >::rbegin ( ) const
inline

◆ rend()

template<class T>
const_iterator cmsutils::bqueue< T >::rend ( ) const
inline

◆ shared()

template<class T>
bool cmsutils::bqueue< T >::shared ( )
inline

Definition at line 211 of file bqueue.h.

Referenced by TempTrajectory::join().

211  {
212  // size = 0: never shared
213  // size = 1: shared if head->refCount > 2 (m_head and m_tail)
214  // size > 1: shared if head->refCount > 2 (m_head and second_hit->back)
215  return (m_size > 0) && (m_head->refCount > 2);
216  }
itemptr m_head
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

◆ size()

template<class T>
size_type cmsutils::bqueue< T >::size ( void  ) const
inline

◆ swap()

template<class T>
void cmsutils::bqueue< T >::swap ( bqueue< T > &  cp)
inline

Definition at line 150 of file bqueue.h.

Referenced by cmsutils::bqueue< TrajectoryMeasurement >::join(), cmsutils::bqueue< TrajectoryMeasurement >::operator=(), cmsutils::bqueue< TrajectoryMeasurement >::swap(), and cmsutils::swap().

150  {
151  using std::swap;
152  swap(m_size, cp.m_size);
153  swap(m_head, cp.m_head);
154  swap(m_tail, cp.m_tail);
155  }
void swap(bqueue< T > &cp)
Definition: bqueue.h:150
itemptr m_head
Definition: bqueue.h:242
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
itemptr m_tail
Definition: bqueue.h:242
size_type m_size
Definition: bqueue.h:241

Member Data Documentation

◆ m_head

template<class T>
itemptr cmsutils::bqueue< T >::m_head
private

◆ m_size

template<class T>
size_type cmsutils::bqueue< T >::m_size
private

◆ m_tail

template<class T>
itemptr cmsutils::bqueue< T >::m_tail
private