12 #include <tracking/trackFindingCDC/numerics/WithWeight.h>
24 namespace TrackFindingCDC {
26 template <
class T,
class AItem>
27 class WithWeightedItems :
public T {
34 using This = WithWeightedItems<T, AItem>;
54 static_cast<Weight
>(0.0),
56 return accumulatedWeight + weightedItem.
getWeight();
61 template <
class APredicate>
62 void eraseIf(
const APredicate& predicate)
73 void insert(
const AItem& item, Weight weight = 1.0)
81 template <
class AMeasure>
82 void insert(
const This& items, AMeasure& measure)
84 for (AItem item : items.m_items) {
85 const Weight weight = measure(item);
86 if (not std::isnan(weight)) {
93 typename std::vector<WithWeight<AItem>>::iterator
begin()
99 typename std::vector<WithWeight<AItem>>::const_iterator
begin()
const
105 typename std::vector<WithWeight<AItem>>::iterator
end()
111 typename std::vector<WithWeight<AItem>>::const_iterator
end()
const
128 Super& super = *
this;
129 clearIfApplicable(super);
134 std::vector<WithWeight<AItem>>
m_items;
137 typename std::vector<WithWeight<AItem>>::iterator
m_itEnd{
m_items.end()};