Template Function mosaic::nearest_by_key#

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. items must be ascending by keyOf(item) (already guaranteed by every caller’s own load() step). Returns nullptr for an empty container; otherwise the item whose key is closest to estimate, clamping to the first/last item when estimate falls outside the container’s range, and preferring the earlier item on an exact tie between neighbors.