ATLAS Offline Software
Loading...
Searching...
No Matches
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 acceptNoSort ()
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 222 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 223 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 226 of file MeasurementSelector.h.

226 {
227 init(max_n);
228 }
void init(std::size_t max_n)

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

260 {
261 // bubble best element to top
262 for (unsigned int slot_i = m_nextSlot;
263 slot_i-- > 0
266 }
267 // if there are still free slot increase the number of used slots
268 if (m_nextSlot < m_maxSlots) {
269 ++m_nextSlot;
271 }
272 }
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
std::array< PayloadType, N+1 > m_slots
std::array< IndexType, N+1 > m_order

◆ acceptNoSort()

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

Definition at line 274 of file MeasurementSelector.h.

274 {
275 // if there are still free slot increase the number of used slots
276 if (m_nextSlot < m_maxSlots) {
277 ++m_nextSlot;
279 }
280 return (m_nextSlot < m_maxSlots);
281 }

◆ begin()

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

Definition at line 290 of file MeasurementSelector.h.

290{ return m_order.begin(); }

◆ empty()

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

Definition at line 283 of file MeasurementSelector.h.

283 {
284 return m_nextSlot==0;
285 }

◆ end()

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

Definition at line 291 of file MeasurementSelector.h.

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

250 {
251 return m_slots[idx];
252 }

◆ getSlot() [2/2]

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

Definition at line 245 of file MeasurementSelector.h.

245 {
246 return m_slots[idx];
247 }

◆ init()

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

Definition at line 232 of file MeasurementSelector.h.

232 {
233 assert( max_n < N);
234 m_nextSlot=0;
236 m_order[0]=0;
237 }

◆ isValid()

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

Definition at line 254 of file MeasurementSelector.h.

254 {
255 return idx < m_nextSlot;
256 }

◆ size()

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

Definition at line 287 of file MeasurementSelector.h.

287{ return m_nextSlot; }

◆ slot()

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

Definition at line 240 of file MeasurementSelector.h.

240 {
241 return m_slots[m_order[m_nextSlot] ];
242 }

Member Data Documentation

◆ m_maxSlots

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

Definition at line 296 of file MeasurementSelector.h.

◆ m_nextSlot

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

Definition at line 295 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 294 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 293 of file MeasurementSelector.h.


The documentation for this struct was generated from the following file: