ATLAS Offline Software
Public Types | Public Member Functions | Public Attributes | List of all members
TopCollection< N, PayloadType > Struct Template Reference

#include <MeasurementSelector.h>

Collaboration diagram for TopCollection< N, PayloadType >:

Public Types

using IndexType = unsigned short
 

Public Member Functions

 TopCollection (std::size_t max_n)
 
void init (std::size_t max_n)
 
PayloadType & slot ()
 
const PayloadType & getSlot (IndexType idx) const
 
PayloadType & getSlot (IndexType idx)
 
bool isValid (IndexType idx) const
 
void acceptAndSort (std::function< bool(const PayloadType &a, const PayloadType &b)> comparison)
 
bool empty () const
 
IndexType size () const
 
std::array< IndexType, N+1 >::const_iterator begin ()
 
std::array< IndexType, N+1 >::const_iterator end ()
 

Public Attributes

std::array< PayloadType, N+1 > m_slots
 
std::array< IndexType, N+1 > m_order
 
IndexType m_nextSlot = 0
 
IndexType m_maxSlots = 0
 

Detailed Description

template<std::size_t N, class PayloadType>
struct TopCollection< N, PayloadType >

Definition at line 219 of file MeasurementSelector.h.

Member Typedef Documentation

◆ IndexType

template<std::size_t N, class PayloadType >
using TopCollection< N, PayloadType >::IndexType = unsigned short

Definition at line 220 of file MeasurementSelector.h.

Constructor & Destructor Documentation

◆ TopCollection()

template<std::size_t N, class PayloadType >
TopCollection< N, PayloadType >::TopCollection ( std::size_t  max_n)
inline

Definition at line 223 of file MeasurementSelector.h.

223  {
224  init(max_n);
225  }

Member Function Documentation

◆ acceptAndSort()

template<std::size_t N, class PayloadType >
void TopCollection< N, PayloadType >::acceptAndSort ( std::function< bool(const PayloadType &a, const PayloadType &b)>  comparison)
inline

Definition at line 257 of file MeasurementSelector.h.

257  {
258  // bubble best element to top
259  for (unsigned int slot_i = m_nextSlot;
260  slot_i-- > 0
261  && !comparison(m_slots[ m_order[slot_i] ],m_slots[ m_order[slot_i+1] ]);) {
262  std::swap(m_order[slot_i],m_order[slot_i+1]);
263  }
264  // if there are still free slot increase the number of used slots
265  if (m_nextSlot < m_maxSlots) {
266  ++m_nextSlot;
268  }
269  }

◆ begin()

template<std::size_t N, class PayloadType >
std::array<IndexType, N+1>::const_iterator TopCollection< N, PayloadType >::begin ( )
inline

Definition at line 278 of file MeasurementSelector.h.

278 { return m_order.begin(); }

◆ empty()

template<std::size_t N, class PayloadType >
bool TopCollection< N, PayloadType >::empty ( ) const
inline

Definition at line 271 of file MeasurementSelector.h.

271  {
272  return m_nextSlot==0;
273  }

◆ end()

template<std::size_t N, class PayloadType >
std::array<IndexType, N+1>::const_iterator TopCollection< N, PayloadType >::end ( )
inline

Definition at line 279 of file MeasurementSelector.h.

279 { return m_order.begin()+m_nextSlot; }

◆ getSlot() [1/2]

template<std::size_t N, class PayloadType >
PayloadType& TopCollection< N, PayloadType >::getSlot ( IndexType  idx)
inline

Definition at line 247 of file MeasurementSelector.h.

247  {
248  return m_slots[idx];
249  }

◆ getSlot() [2/2]

template<std::size_t N, class PayloadType >
const PayloadType& TopCollection< N, PayloadType >::getSlot ( IndexType  idx) const
inline

Definition at line 242 of file MeasurementSelector.h.

242  {
243  return m_slots[idx];
244  }

◆ init()

template<std::size_t N, class PayloadType >
void TopCollection< N, PayloadType >::init ( std::size_t  max_n)
inline

Definition at line 229 of file MeasurementSelector.h.

229  {
230  assert( max_n < N);
231  m_nextSlot=0;
232  m_maxSlots=max_n;
233  m_order[0]=0;
234  }

◆ isValid()

template<std::size_t N, class PayloadType >
bool TopCollection< N, PayloadType >::isValid ( IndexType  idx) const
inline

Definition at line 251 of file MeasurementSelector.h.

251  {
252  return idx < m_nextSlot;
253  }

◆ size()

template<std::size_t N, class PayloadType >
IndexType TopCollection< N, PayloadType >::size ( ) const
inline

Definition at line 275 of file MeasurementSelector.h.

275 { return m_nextSlot; }

◆ slot()

template<std::size_t N, class PayloadType >
PayloadType& TopCollection< N, PayloadType >::slot ( )
inline

Definition at line 237 of file MeasurementSelector.h.

237  {
238  return m_slots[m_order[m_nextSlot] ];
239  }

Member Data Documentation

◆ m_maxSlots

template<std::size_t N, class PayloadType >
IndexType TopCollection< N, PayloadType >::m_maxSlots = 0

Definition at line 284 of file MeasurementSelector.h.

◆ m_nextSlot

template<std::size_t N, class PayloadType >
IndexType TopCollection< N, PayloadType >::m_nextSlot = 0

Definition at line 283 of file MeasurementSelector.h.

◆ m_order

template<std::size_t N, class PayloadType >
std::array<IndexType, N+1> TopCollection< N, PayloadType >::m_order

Definition at line 282 of file MeasurementSelector.h.

◆ m_slots

template<std::size_t N, class PayloadType >
std::array<PayloadType, N+1> TopCollection< N, PayloadType >::m_slots

Definition at line 281 of file MeasurementSelector.h.


The documentation for this struct was generated from the following file:
TopCollection::m_slots
std::array< PayloadType, N+1 > m_slots
Definition: MeasurementSelector.h:281
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
TopCollection::m_order
std::array< IndexType, N+1 > m_order
Definition: MeasurementSelector.h:282
TopCollection::m_maxSlots
IndexType m_maxSlots
Definition: MeasurementSelector.h:284
TopCollection::m_nextSlot
IndexType m_nextSlot
Definition: MeasurementSelector.h:283
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TopCollection::init
void init(std::size_t max_n)
Definition: MeasurementSelector.h:229