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 212 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 213 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 216 of file MeasurementSelector.h.

216  {
217  init(max_n);
218  }

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 250 of file MeasurementSelector.h.

250  {
251  // bubble best element to top
252  for (unsigned int slot_i = m_nextSlot;
253  slot_i-- > 0
254  && !comparison(m_slots[ m_order[slot_i] ],m_slots[ m_order[slot_i+1] ]);) {
255  std::swap(m_order[slot_i],m_order[slot_i+1]);
256  }
257  // if there are still free slot increase the number of used slots
258  if (m_nextSlot < m_maxSlots) {
259  ++m_nextSlot;
261  }
262  }

◆ begin()

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

Definition at line 271 of file MeasurementSelector.h.

271 { return m_order.begin(); }

◆ empty()

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

Definition at line 264 of file MeasurementSelector.h.

264  {
265  return m_nextSlot==0;
266  }

◆ end()

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

Definition at line 272 of file MeasurementSelector.h.

272 { 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 240 of file MeasurementSelector.h.

240  {
241  return m_slots[idx];
242  }

◆ getSlot() [2/2]

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

Definition at line 235 of file MeasurementSelector.h.

235  {
236  return m_slots[idx];
237  }

◆ init()

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

Definition at line 222 of file MeasurementSelector.h.

222  {
223  assert( max_n < N);
224  m_nextSlot=0;
225  m_maxSlots=max_n;
226  m_order[0]=0;
227  }

◆ isValid()

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

Definition at line 244 of file MeasurementSelector.h.

244  {
245  return idx < m_nextSlot;
246  }

◆ size()

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

Definition at line 268 of file MeasurementSelector.h.

268 { return m_nextSlot; }

◆ slot()

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

Definition at line 230 of file MeasurementSelector.h.

230  {
231  return m_slots[m_order[m_nextSlot] ];
232  }

Member Data Documentation

◆ m_maxSlots

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

Definition at line 277 of file MeasurementSelector.h.

◆ m_nextSlot

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

Definition at line 276 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 275 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 274 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:274
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
TopCollection::m_order
std::array< IndexType, N+1 > m_order
Definition: MeasurementSelector.h:275
TopCollection::m_maxSlots
IndexType m_maxSlots
Definition: MeasurementSelector.h:277
TopCollection::m_nextSlot
IndexType m_nextSlot
Definition: MeasurementSelector.h:276
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:222