CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::HallOfFame< ObjectType, Metric, ObjectCompare > Class Template Reference

#include <HallOfFame.hh>

Detailed Description

template<typename ObjectType, typename Metric, typename ObjectCompare = std::less<ObjectType>>
class CASM::HallOfFame< ObjectType, Metric, ObjectCompare >

A container for storing best scoring objects.

Essentially a std::map with insert modified to calculate the 'score' of an object and insert while keeping only a particular number of best scoring objects.

ObjectCompare implements comparison of ObjectType objects

Definition at line 21 of file HallOfFame.hh.

Classes

class  Compare
 
struct  InsertResult
 Results data structure for HallOfFame::insert. More...
 

Public Types

typedef std::pair< double, ObjectType > PairType
 
typedef std::set< PairType, CompareContainerType
 
typedef ContainerType::const_iterator const_iterator
 
typedef ContainerType::const_reverse_iterator const_reverse_iterator
 
typedef Index size_type
 

Public Member Functions

 HallOfFame (Metric _metric, ObjectCompare _obj_compare=std::less< ObjectType >(), Index _max_size=100, double _score_tol=TOL)
 Constructor. More...
 
void exclude (const ObjectType &obj)
 Add an object that should not be included in the hall of fame. More...
 
template<typename ObjectIterator >
void exclude (ObjectIterator begin, ObjectIterator end)
 Add objects that should not be included in the hall of fame. More...
 
void clear_excluded ()
 
Metric metric () const
 
bool empty () const
 
size_type size () const
 
size_type max_size () const
 
InsertResult insert (const ObjectType &obj)
 Insert object in HallOfFame. More...
 
void clear ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator end () const
 
const_iterator cend () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
std::pair< const_iterator, const_iteratorequal_range (double key) const
 
size_type count (double key) const
 
const_iterator find (double key) const
 
const_iterator lower_bound (double key) const
 
const_iterator upper_bound (double key) const
 

Private Attributes

Metric m_metric
 
ObjectCompare m_obj_compare
 
FloatCompare m_score_compare
 
ContainerType m_halloffame
 
bool m_check_exclude
 
ContainerType m_exclude
 
Index m_max_size
 

Member Typedef Documentation

◆ const_iterator

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
typedef ContainerType::const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::const_iterator

Definition at line 48 of file HallOfFame.hh.

◆ const_reverse_iterator

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
typedef ContainerType::const_reverse_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::const_reverse_iterator

Definition at line 49 of file HallOfFame.hh.

◆ ContainerType

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
typedef std::set<PairType, Compare> CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::ContainerType

Definition at line 47 of file HallOfFame.hh.

◆ PairType

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
typedef std::pair<double, ObjectType> CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::PairType

Definition at line 23 of file HallOfFame.hh.

◆ size_type

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
typedef Index CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::size_type

Definition at line 50 of file HallOfFame.hh.

Constructor & Destructor Documentation

◆ HallOfFame()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::HallOfFame ( Metric  _metric,
ObjectCompare  _obj_compare = std::less<ObjectType>(),
Index  _max_size = 100,
double  _score_tol = TOL 
)
inline

Constructor.

Parameters
_metricA function scoring 'ObjectType' objects
_obj_compareFunctor implementing comparison of 'ObjectType' objects
_max_sizeThe maximum number of 'ObjectType' objects to store in the HallOfFame
_metric_tolThe tolerance used for comparing scores, via FloatCompare

Definition at line 87 of file HallOfFame.hh.

Member Function Documentation

◆ begin()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::begin ( ) const
inline

Definition at line 173 of file HallOfFame.hh.

◆ cbegin()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::cbegin ( ) const
inline

Definition at line 175 of file HallOfFame.hh.

◆ cend()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::cend ( ) const
inline

Definition at line 179 of file HallOfFame.hh.

◆ clear()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
void CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::clear ( )
inline

Definition at line 171 of file HallOfFame.hh.

◆ clear_excluded()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
void CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::clear_excluded ( )
inline

Definition at line 112 of file HallOfFame.hh.

◆ count()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
size_type CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::count ( double  key) const
inline

Definition at line 193 of file HallOfFame.hh.

◆ crbegin()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_reverse_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::crbegin ( ) const
inline

Definition at line 183 of file HallOfFame.hh.

◆ crend()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_reverse_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::crend ( ) const
inline

Definition at line 187 of file HallOfFame.hh.

◆ empty()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
bool CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::empty ( ) const
inline

Definition at line 116 of file HallOfFame.hh.

◆ end()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::end ( ) const
inline

Definition at line 177 of file HallOfFame.hh.

◆ equal_range()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
std::pair<const_iterator, const_iterator> CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::equal_range ( double  key) const
inline

Definition at line 189 of file HallOfFame.hh.

◆ exclude() [1/2]

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
void CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::exclude ( const ObjectType &  obj)
inline

Add an object that should not be included in the hall of fame.

Definition at line 99 of file HallOfFame.hh.

◆ exclude() [2/2]

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
template<typename ObjectIterator >
void CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::exclude ( ObjectIterator  begin,
ObjectIterator  end 
)
inline

Add objects that should not be included in the hall of fame.

Definition at line 106 of file HallOfFame.hh.

◆ find()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::find ( double  key) const
inline

Definition at line 195 of file HallOfFame.hh.

◆ insert()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
InsertResult CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::insert ( const ObjectType &  obj)
inline

Insert object in HallOfFame.

  • Will score object, and insert into HallOfFame, erasing the worst scoring member if necessary to maintain the max_size specified at construction

Definition at line 126 of file HallOfFame.hh.

◆ lower_bound()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::lower_bound ( double  key) const
inline

Definition at line 197 of file HallOfFame.hh.

◆ max_size()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
size_type CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::max_size ( ) const
inline

Definition at line 120 of file HallOfFame.hh.

◆ metric()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
Metric CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::metric ( ) const
inline

Definition at line 114 of file HallOfFame.hh.

◆ rbegin()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_reverse_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::rbegin ( ) const
inline

Definition at line 181 of file HallOfFame.hh.

◆ rend()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_reverse_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::rend ( ) const
inline

Definition at line 185 of file HallOfFame.hh.

◆ size()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
size_type CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::size ( ) const
inline

Definition at line 118 of file HallOfFame.hh.

◆ upper_bound()

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
const_iterator CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::upper_bound ( double  key) const
inline

Definition at line 201 of file HallOfFame.hh.

Member Data Documentation

◆ m_check_exclude

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
bool CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::m_check_exclude
private

Definition at line 210 of file HallOfFame.hh.

◆ m_exclude

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
ContainerType CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::m_exclude
private

Definition at line 211 of file HallOfFame.hh.

◆ m_halloffame

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
ContainerType CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::m_halloffame
private

Definition at line 209 of file HallOfFame.hh.

◆ m_max_size

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
Index CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::m_max_size
private

Definition at line 212 of file HallOfFame.hh.

◆ m_metric

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
Metric CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::m_metric
private

Definition at line 206 of file HallOfFame.hh.

◆ m_obj_compare

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
ObjectCompare CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::m_obj_compare
private

Definition at line 207 of file HallOfFame.hh.

◆ m_score_compare

template<typename ObjectType , typename Metric , typename ObjectCompare = std::less<ObjectType>>
FloatCompare CASM::HallOfFame< ObjectType, Metric, ObjectCompare >::m_score_compare
private

Definition at line 208 of file HallOfFame.hh.


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