codac 2.0.0
Loading...
Searching...
No Matches
codac2::VectorCompare Struct Reference

Comparison functor for codac2::Vector objects. More...

#include <codac2_Vector.h>

Public Member Functions

bool operator() (const Vector &a, const Vector &b) const
 Defines an increasing-order comparison between two vectors of real numbers.
 

Detailed Description

Comparison functor for codac2::Vector objects.

This functor defines a strict weak ordering on codac2::Vector objects so that they can be used as keys in associative containers such as std::map. The ordering is based on increasing real values, inspected sequentially from index 0 to the last. If all corresponding components are equal, the operator returns false to indicate that neither vector is strictly less than the other.

Member Function Documentation

◆ operator()()

bool codac2::VectorCompare::operator() ( const Vector & a,
const Vector & b ) const
inline

Defines an increasing-order comparison between two vectors of real numbers.

Parameters
aThe first vector to compare.
bThe second vector to compare.
Returns
true if a is considered strictly smaller than b, false otherwise.
60 {
61 if(a.size() != b.size())
62 return a.size() < b.size();
63
64 for(Index i = 0 ; i < a.size() ; i++)
65 if(a[i] != b[i])
66 return a[i] < b[i];
67
68 return false;
69 }

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