Added order_by_descending_distance()

This commit is contained in:
Davis King 2013-07-01 17:31:21 -04:00
parent 2d034a58a0
commit 7f22ec06b8
2 changed files with 23 additions and 0 deletions

View File

@ -95,6 +95,15 @@ namespace dlib
return a.distance() < b.distance();
}
template <typename T>
inline bool order_by_descending_distance (
const T& a,
const T& b
)
{
return a.distance() > b.distance();
}
template <typename T>
bool order_by_distance_and_index (
const T& a,

View File

@ -114,6 +114,20 @@ namespace dlib
used with std::sort().
!*/
template <typename T>
bool order_by_descending_distance (
const T& a,
const T& b
) { return a.distance() > b.distance(); }
/*!
requires
- T is a type with an interface compatible with sample_pair.
ensures
- provides a total ordering of sample_pair objects that causes pairs with
largest distance to be the first in a sorted list. This function can be
used with std::sort().
!*/
template <typename T>
bool order_by_distance_and_index (
const T& a,