CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
Public Types | Public Member Functions | Private Attributes

claw::max_vector< E, Comp, Container > Class Template Reference

Fill a container with some values, keeping only all the "maximum" inserted values. More...

#include <max_vector.hpp>

List of all members.

Public Types

typedef E value_type
 The type of the values stored in the container.
typedef Comp comparator_type
 The comparator used to compare the values inserted.
typedef Container container_type
 The type of the container in which the values are stored.

Public Member Functions

 max_vector ()
 Constructor.
 max_vector (const value_type &e)
 Constructor with an initial value.
void add (const value_type &e)
 Insert a value in the vector.
const container_typeget_v () const
 Get the stored values.

Private Attributes

container_type m_values
 The maximum values.

Detailed Description

template<typename E, typename Comp = std::less<E>, typename Container = std::vector<E>>
class claw::max_vector< E, Comp, Container >

Fill a container with some values, keeping only all the "maximum" inserted values.

Adding a value greater than the previous ones remove all the old values.

Template parameters:

Definition at line 55 of file max_vector.hpp.


Member Typedef Documentation

template<typename E, typename Comp = std::less<E>, typename Container = std::vector<E>>
typedef Comp claw::max_vector< E, Comp, Container >::comparator_type

The comparator used to compare the values inserted.

Definition at line 62 of file max_vector.hpp.

template<typename E, typename Comp = std::less<E>, typename Container = std::vector<E>>
typedef Container claw::max_vector< E, Comp, Container >::container_type

The type of the container in which the values are stored.

Definition at line 65 of file max_vector.hpp.

template<typename E, typename Comp = std::less<E>, typename Container = std::vector<E>>
typedef E claw::max_vector< E, Comp, Container >::value_type

The type of the values stored in the container.

Definition at line 59 of file max_vector.hpp.


Constructor & Destructor Documentation

template<typename E , typename Comp , typename Container >
claw::max_vector< E, Comp, Container >::max_vector ( )

Constructor.

Definition at line 36 of file max_vector.tpp.

{ 

} // max_vector::max_vector()
template<typename E , typename Comp , typename Container >
claw::max_vector< E, Comp, Container >::max_vector ( const value_type e) [explicit]

Constructor with an initial value.

Parameters:
eélément ajouté.

Definition at line 47 of file max_vector.tpp.

{ 
  add(e);
} // max_vector::max_vector()

Member Function Documentation

template<typename E , typename Comp , typename Container >
void claw::max_vector< E, Comp, Container >::add ( const value_type e)

Insert a value in the vector.

Parameters:
eThe value to insert.

Definition at line 58 of file max_vector.tpp.

Referenced by claw::ai::game::select_random_action< Method >::operator()().

{
  if (m_values.empty())
    *std::inserter(m_values, m_values.end()) = e;
  else
    {
      comparator_type comp;
      if ( comp(m_values.front(), e) )
  {
    m_values.clear();
    *std::inserter(m_values, m_values.end()) = e;
  }
      else if ( !comp(e, m_values.front()) )
  *std::inserter(m_values, m_values.end()) = e;
    }
} // max_vector::add()
template<typename E , typename Comp , typename Container >
const claw::max_vector< E, Comp, Container >::container_type & claw::max_vector< E, Comp, Container >::get_v ( ) const

Get the stored values.

Definition at line 81 of file max_vector.tpp.

Referenced by claw::ai::game::select_random_action< Method >::operator()().

{ 
  return m_values; 
} // max_vector::get_v()

Member Data Documentation

template<typename E, typename Comp = std::less<E>, typename Container = std::vector<E>>
container_type claw::max_vector< E, Comp, Container >::m_values [private]

The maximum values.

Definition at line 76 of file max_vector.hpp.


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