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

#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 ()
 

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 632 of file util.h.

Constructor & Destructor Documentation

◆ TopN()

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

Definition at line 634 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 641 of file util.h.

◆ Clear()

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

Definition at line 636 of file util.h.

◆ empty()

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

Definition at line 662 of file util.h.

◆ MutableUnorderedElements()

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

Definition at line 665 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 664 of file util.h.


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