23 size_t maxElms()
const {
return maxElms_; }
26 bool empty()
const {
return heap_.empty(); }
29 size_t size()
const {
return heap_.size(); }
35 const std::vector<T> &
get()
const {
return heap_; }
38 const T &
top()
const { assert( !heap_.empty() );
return heap_.front(); }
41 const T &
topOr(
const T & emptyRes )
const {
return !heap_.empty() ? heap_.front() : emptyRes; }
58 heap_.reserve( maxElms );
65 assert( heap_.size() <= maxElms() );
66 if ( heap_.size() == maxElms() )
68 if ( t < heap_.front() )
70 std::pop_heap( heap_.begin(), heap_.end() );
71 assert( t < heap_.back() );
72 heap_.back() = std::move( t );
73 std::push_heap( heap_.begin(), heap_.end() );
77 heap_.push_back( std::move( t ) );
78 std::push_heap( heap_.begin(), heap_.end() );
the class stores some number of smallest elements from a larger number of candidates
Definition MRFewSmallest.h:14
void push(T t)
considers one more element, storing it if it is within the smallest
Definition MRFewSmallest.h:63
const T & top() const
returns the largest among stored smallest elements
Definition MRFewSmallest.h:38
void reset(size_t maxElms)
clears the content and reconfigure the object to store at most given number of elements
Definition MRFewSmallest.h:55
const T & topOr(const T &emptyRes) const
returns the largest among stored smallest elements or given element if this is empty
Definition MRFewSmallest.h:41
bool empty() const
returns whether the container is currently empty
Definition MRFewSmallest.h:26
const std::vector< T > & get() const
returns the smallest elements found so far
Definition MRFewSmallest.h:35
size_t maxElms() const
returns the maximum number of elements to be stored here
Definition MRFewSmallest.h:23
size_t size() const
returns current number of stored element
Definition MRFewSmallest.h:29
bool full() const
returns whether we have already maximum number of elements stored
Definition MRFewSmallest.h:32
void clear()
removes all stored elements
Definition MRFewSmallest.h:47
FewSmallest(size_t maxElms=0)
configure the object to store at most given number of elements
Definition MRFewSmallest.h:17
Definition MRCameraOrientationPlugin.h:8