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 (bqueue< T > &&cp) noexcept
 
 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
 
bqueueoperator= (bqueue< T > const &)=default
 
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() {}

◆ ~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) {}

◆ 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  }

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(); }

◆ clear()

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

Definition at line 235 of file bqueue.h.

235  {
236  m_head = m_tail = nullptr;
237  m_size = 0;
238  }

Referenced by TempTrajectory::join().

◆ 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.

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  }

Referenced by TempTrajectory::emplace().

◆ empty()

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

Definition at line 202 of file bqueue.h.

202 { return m_size == 0; }

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

◆ 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.

193 { return m_head->value; }

Referenced by TempTrajectory::firstMeasurement().

◆ join()

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

Definition at line 220 of file bqueue.h.

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  }

Referenced by TempTrajectory::join().

◆ operator=() [1/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  }

◆ operator=() [2/2]

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

◆ 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  }

◆ pop_back()

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

Definition at line 184 of file bqueue.h.

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  }

Referenced by TempTrajectory::pop().

◆ 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.

160  {
161  m_tail = itemptr(new item(this->m_tail, val));
162  if ((++m_size) == 1) {
163  m_head = m_tail;
164  };
165  }

Referenced by TempTrajectory::push().

◆ 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  }

◆ 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.

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  }

Referenced by TempTrajectory::join().

◆ 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

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
writedatasetfile.args
args
Definition: writedatasetfile.py:18
cmsutils::bqueue::m_size
size_type m_size
Definition: bqueue.h:241
mps_fire.i
i
Definition: mps_fire.py:428
cmsutils::bqueue::swap
void swap(bqueue< T > &cp)
Definition: bqueue.h:150
cms::cuda::assert
assert(be >=bs)
hgcal_conditions::parameters
Definition: HGCConditions.h:86
cmsutils::bqueue::itemptr
boost::intrusive_ptr< _bqueue_item< value_type > > itemptr
Definition: bqueue.h:127
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
trackingPlots.other
other
Definition: trackingPlots.py:1460
cmsutils::bqueue::rbegin
const_iterator rbegin() const
Definition: bqueue.h:197
cmsutils::bqueue::item
_bqueue_item< value_type > item
Definition: bqueue.h:126
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
cmsutils::bqueue::m_tail
itemptr m_tail
Definition: bqueue.h:242
cmsutils::bqueue::m_head
itemptr m_head
Definition: bqueue.h:242
cmsutils::bqueue::const_iterator
_bqueue_itr< value_type > const_iterator
Definition: bqueue.h:129