Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::sat::TopN< Element, Score > Class Template Reference

Detailed Description

template<typename Element, typename Score>
class operations_research::sat::TopN< Element, Score >

Keep the top n elements from a stream of elements.

Todo
(user): We could use gtl::TopN when/if it gets open sourced. Note that we might be slighlty faster here since we use an indirection and don't move the Element class around as much.

Definition at line 681 of file util.h.

#include <util.h>

Public Member Functions

 TopN (int n)
void Clear ()
void Add (Element e, Score score)
bool empty () const
const std::vector< Element > & UnorderedElements () const
std::vector< Element > * MutableUnorderedElements ()

Constructor & Destructor Documentation

◆ TopN()

template<typename Element, typename Score>
operations_research::sat::TopN< Element, Score >::TopN ( int n)
inlineexplicit

Definition at line 683 of file util.h.

Member Function Documentation

◆ Add()

template<typename Element, typename Score>
void operations_research::sat::TopN< Element, Score >::Add ( Element e,
Score score )
inline
Todo
(user): We could delay that on the n + 1 push.

If needed, we could be faster here with an update operation.

Definition at line 690 of file util.h.

◆ Clear()

template<typename Element, typename Score>
void operations_research::sat::TopN< Element, Score >::Clear ( )
inline

Definition at line 685 of file util.h.

◆ empty()

template<typename Element, typename Score>
bool operations_research::sat::TopN< Element, Score >::empty ( ) const
inline

Definition at line 711 of file util.h.

◆ MutableUnorderedElements()

template<typename Element, typename Score>
std::vector< Element > * operations_research::sat::TopN< Element, Score >::MutableUnorderedElements ( )
inline

Definition at line 714 of file util.h.

◆ UnorderedElements()

template<typename Element, typename Score>
const std::vector< Element > & operations_research::sat::TopN< Element, Score >::UnorderedElements ( ) const
inline

Definition at line 713 of file util.h.


The documentation for this class was generated from the following file: