algo/search: return the score and the object in minimises

This commit is contained in:
Danny Robson 2018-11-19 15:35:56 +11:00
parent 0138b00f87
commit e26165cea9
2 changed files with 3 additions and 3 deletions

View File

@ -61,6 +61,6 @@ namespace cruft::search {
}
}
return best_item;
return std::pair (std::move (best_score), std::move (best_item));
}
}

View File

@ -30,14 +30,14 @@ main (void)
};
auto best = cruft::search::minimises (
auto const [best_score, best_iterator] = cruft::search::minimises (
std::begin (src),
std::end (src),
[] (auto const a, auto const b) { return cruft::distance2 (a, b); },
dst
);
tap.expect_eq (best, src + 2, "minimises point3 using distance2");
tap.expect_eq (best_iterator, src + 2, "minimises point3 using distance2");
}