10#include <tracking/trackFindingCDC/numerics/Weight.h>
22 namespace TrackFindingCDC {
25 template <
class AFrom,
class ATo = AFrom>
29 using Super = std::pair<std::pair<AFrom*, Weight>, ATo*>;
44 :
Super({from, weight}, to)
59 friend bool operator<(
const std::pair<From*, Weight>& weightedPtr,
62 return (weightedPtr.first < weightedRelation.
getFrom() or
63 (not(weightedRelation.
getFrom() < weightedPtr.first) and
65 (weightedPtr.second > weightedRelation.
getWeight())));
70 const std::pair<From*, Weight>& weightedPtr)
72 return (weightedRelation.
getFrom() < weightedPtr.first or
73 (not(weightedPtr.first < weightedRelation.
getFrom()) and
75 (weightedRelation.
getWeight() > weightedPtr.second)));
81 return ptrFrom < weightedRelation.
getFrom();
87 return weightedRelation.
getFrom() < ptrFrom;
105 this->first.second = weight;
129 template <
class AFrom,
class ATo = AFrom>
136 template <
class AWeightedRelations>
139 static_assert(std::is_same<AFrom, ATo>::value,
"Symmetric check requires some types in From and To");
140 assert(std::is_sorted(std::begin(weightedRelations), std::end(weightedRelations)));
141 auto reversedRelationExists =
143 auto reversedRelations = std::equal_range(std::begin(weightedRelations),
144 std::end(weightedRelations),
145 weightedRelation.reversed());
146 return reversedRelations.first != reversedRelations.second;
148 return std::all_of(std::begin(weightedRelations),
149 std::end(weightedRelations),
150 reversedRelationExists);
Type for two related objects with a weight.
Weight getWeight() const
Getter for the weight.
friend bool operator<(const WeightedRelation< From, To > &weightedRelation, const From *ptrFrom)
Operator to compare key type item to the relations for associative lookups.
From * getFrom() const
Getter for the pointer to the from side object.
friend bool operator<(const WeightedRelation< From, To > &weightedRelation, const std::pair< From *, Weight > &weightedPtr)
Operator to compare key type weighted item to the relations for associative lookups.
WeightedRelation(From *from, Weight weight, To *to)
Creating a relation with one object on the from side, one on the to side and a weight.
AFrom From
Type of from which the relation originates.
const std::pair< From *, Weight > & getWeightedFrom() const
Getter for the pointer to the weighted from side object.
friend bool operator<(const std::pair< From *, Weight > &weightedPtr, const WeightedRelation< From, To > &weightedRelation)
Operator to compare key type weighted item to the relations for associative lookups.
void setWeight(Weight weight)
Setter for the weight.
ATo To
Type of to which the relation points.
To * getTo() const
Getter for the pointer to the to side object.
friend bool operator<(const From *ptrFrom, const WeightedRelation< From, To > &weightedRelation)
Operator to compare key type item to the relations for associative lookups.
bool operator<(const WeightedRelation< From, To > &rhs) const
Operator for ordering of relations.
WeightedRelation< To, From > reversed() const
Make a relation in the opposite direction with the same weight.
WeightedRelation()=default
Default constructor.
std::pair< std::pair< AFrom *, Weight >, ATo * > Super
Type of the base class.
Abstract base class for different kinds of events.
Utility structure with functions related to weighted relations.
static bool areSymmetric(const AWeightedRelations &weightedRelations)
Checks for the symmetry of a range of weighted relations Explicitly checks for each weighted relation...