Belle II Software development
WeightedRelationUtil< AFrom, ATo > Struct Template Reference

Utility structure with functions related to weighted relations. More...

#include <WeightedRelation.h>

Static Public Member Functions

template<class AWeightedRelations >
static bool areSymmetric (const AWeightedRelations &weightedRelations)
 Checks for the symmetry of a range of weighted relations Explicitly checks for each weighted relation, if their is an reverse relation with the same weight.
 

Detailed Description

template<class AFrom, class ATo = AFrom>
struct Belle2::TrackFindingCDC::WeightedRelationUtil< AFrom, ATo >

Utility structure with functions related to weighted relations.

Definition at line 130 of file WeightedRelation.h.

Member Function Documentation

◆ areSymmetric()

static bool areSymmetric ( const AWeightedRelations &  weightedRelations)
inlinestatic

Checks for the symmetry of a range of weighted relations Explicitly checks for each weighted relation, if their is an reverse relation with the same weight.

Returns true if all such inverse relations exist.

Definition at line 137 of file WeightedRelation.h.

138 {
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 =
142 [&weightedRelations](const WeightedRelation<AFrom, ATo>& weightedRelation) -> bool {
143 auto reversedRelations = std::equal_range(std::begin(weightedRelations),
144 std::end(weightedRelations),
145 weightedRelation.reversed());
146 return reversedRelations.first != reversedRelations.second;
147 };
148 return std::all_of(std::begin(weightedRelations),
149 std::end(weightedRelations),
150 reversedRelationExists);
151 }

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