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

257 {
258 // bubble best element to top
259 for (unsigned int slot_i = m_nextSlot;
260 slot_i-- > 0
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 }
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 271 of file MeasurementSelector.h.

271 {
272 // if there are still free slot increase the number of used slots
273 if (m_nextSlot < m_maxSlots) {
274 ++m_nextSlot;
276 }
277 return (m_nextSlot < m_maxSlots);
278 }

◆ begin()

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

Definition at line 287 of file MeasurementSelector.h.

287{ return m_order.begin(); }

◆ empty()

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

Definition at line 280 of file MeasurementSelector.h.

280 {
281 return m_nextSlot==0;
282 }

◆ end()

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

Definition at line 288 of file MeasurementSelector.h.

288{ 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;
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 284 of file MeasurementSelector.h.

284{ 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 293 of file MeasurementSelector.h.

◆ m_nextSlot

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

Definition at line 292 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 291 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 290 of file MeasurementSelector.h.


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