Template Function mosaic::nearest_by_key#
Defined in File nearest_by_key.hpp
Function Documentation#
-
template<typename T, typename Key, typename KeyOf>
const T *mosaic::nearest_by_key(const QVector<T> &items, Key estimate, KeyOf keyOf)# Binary-search “nearest by key” lookup, shared by every per-frame/per-window analysis result class (PoseAnalysisResult, GazeFusionResult, ExpressionResult, Skeleton3DResult, RppgResult’s nearest_window()/ nearest_frame()) — previously an identical, independently-duplicated std::lower_bound + before/after-edge-clamp + numerically-closer tie-break implementation in each of those 6 files.
itemsmust be ascending bykeyOf(item)(already guaranteed by every caller’s own load() step). Returns nullptr for an empty container; otherwise the item whose key is closest toestimate, clamping to the first/last item whenestimatefalls outside the container’s range, and preferring the earlier item on an exact tie between neighbors.