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 130 of file bqueue.h.

◆ item

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

Definition at line 127 of file bqueue.h.

◆ itemptr

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

Definition at line 128 of file bqueue.h.

◆ iterator

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

Definition at line 129 of file bqueue.h.

◆ size_type

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

Definition at line 126 of file bqueue.h.

◆ value_type

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

Definition at line 125 of file bqueue.h.

Constructor & Destructor Documentation

◆ bqueue() [1/3]

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

Definition at line 132 of file bqueue.h.

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

◆ ~bqueue()

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

Definition at line 133 of file bqueue.h.

133 {}

◆ bqueue() [2/3]

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

Definition at line 135 of file bqueue.h.

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

◆ bqueue() [3/3]

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

Definition at line 138 of file bqueue.h.

138  : m_size(cp.m_size), m_head(std::move(cp.m_head)), m_tail(std::move(cp.m_tail)) {
139  cp.m_size = 0;
140  }
itemptr m_head
Definition: bqueue.h:243
itemptr m_tail
Definition: bqueue.h:243
size_type m_size
Definition: bqueue.h:242
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 200 of file bqueue.h.

200 { return m_tail.get(); }
itemptr m_tail
Definition: bqueue.h:243

◆ clear()

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

Definition at line 236 of file bqueue.h.

Referenced by TempTrajectory::join().

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

◆ emplace_back()

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

Definition at line 178 of file bqueue.h.

Referenced by TempTrajectory::emplace().

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

◆ empty()

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

Definition at line 203 of file bqueue.h.

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

203 { return m_size == 0; }
size_type m_size
Definition: bqueue.h:242

◆ end()

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

Definition at line 201 of file bqueue.h.

201 { return nullptr; }

◆ fork()

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

Definition at line 158 of file bqueue.h.

158 { return *this; }

◆ front()

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

Definition at line 194 of file bqueue.h.

Referenced by TempTrajectory::firstMeasurement().

194 { return m_head->value; }
itemptr m_head
Definition: bqueue.h:243

◆ join()

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

Definition at line 221 of file bqueue.h.

Referenced by TempTrajectory::join().

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

◆ 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 143 of file bqueue.h.

143  {
144  using std::swap;
145  swap(m_size, cp.m_size);
146  swap(m_head, cp.m_head);
147  swap(m_tail, cp.m_tail);
148  return *this;
149  }
void swap(bqueue< T > &cp)
Definition: bqueue.h:151
void swap(bqueue< T > &rh, bqueue< T > &lh)
Definition: bqueue.h:247
itemptr m_head
Definition: bqueue.h:243
itemptr m_tail
Definition: bqueue.h:243
size_type m_size
Definition: bqueue.h:242

◆ operator[]()

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

Definition at line 204 of file bqueue.h.

204  {
205  int idx = m_size - i - 1;
207  while (idx-- > 0)
208  --it;
209  return *it;
210  }
const_iterator rbegin() const
Definition: bqueue.h:198
_bqueue_itr< value_type > const_iterator
Definition: bqueue.h:130
size_type m_size
Definition: bqueue.h:242

◆ pop_back()

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

Definition at line 185 of file bqueue.h.

Referenced by TempTrajectory::pop().

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

◆ push_back() [1/2]

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

Definition at line 161 of file bqueue.h.

Referenced by TempTrajectory::push().

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

◆ push_back() [2/2]

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

Definition at line 169 of file bqueue.h.

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

◆ 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 212 of file bqueue.h.

Referenced by TempTrajectory::join().

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

◆ 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 151 of file bqueue.h.

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

151  {
152  using std::swap;
153  swap(m_size, cp.m_size);
154  swap(m_head, cp.m_head);
155  swap(m_tail, cp.m_tail);
156  }
void swap(bqueue< T > &cp)
Definition: bqueue.h:151
void swap(bqueue< T > &rh, bqueue< T > &lh)
Definition: bqueue.h:247
itemptr m_head
Definition: bqueue.h:243
itemptr m_tail
Definition: bqueue.h:243
size_type m_size
Definition: bqueue.h:242

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