Empirical
Classes | Public Member Functions | List of all members
emp::UnorderedIndexMap Class Reference

#include <UnorderedIndexMap.h>

Public Member Functions

 UnorderedIndexMap (size_t _items=0, double init_weight=0.0)
 
 UnorderedIndexMap (const UnorderedIndexMap &)=default
 
 UnorderedIndexMap (UnorderedIndexMap &&)=default
 
 ~UnorderedIndexMap ()=default
 
UnorderedIndexMapoperator= (const UnorderedIndexMap &)=default
 
UnorderedIndexMapoperator= (UnorderedIndexMap &&)=default
 
size_t GetSize () const
 How many indices are in this map? More...
 
double GetWeight () const
 What is the total weight of all indices in this map? More...
 
double RawWeight (size_t id) const
 What is the current weight of the specified index? More...
 
double GetWeight (size_t id) const
 
double RawProb (size_t id) const
 What is the probability of the specified index being selected? More...
 
double GetProb (size_t id) const
 
void Resize (size_t new_size, double def_value=0.0)
 Change the number of indecies in the map. More...
 
size_t size () const
 Standard library compatibility. More...
 
void resize (size_t new_size)
 Standard library compatibility. More...
 
void Clear ()
 Reset all item weights to zero. More...
 
void ResizeClear (size_t new_size)
 Change the size of this map AND change all weights to zero. More...
 
void RawAdjust (size_t id, const double new_weight)
 
void Adjust (size_t id, const double new_weight)
 
void Adjust (const emp::vector< double > &new_weights)
 Adjust all index weights to the set provided. More...
 
void AdjustAll (double new_weight)
 Adjust all index weights to the set provided. More...
 
size_t Index (double index, size_t cur_id=0) const
 Determine the ID at the specified index position. More...
 
Proxy operator[] (size_t id)
 Index into a specified ID. More...
 
double operator[] (size_t id) const
 
UnorderedIndexMapoperator+= (UnorderedIndexMap &in_map)
 Add the weights in another index map to this one. More...
 
UnorderedIndexMapoperator-= (UnorderedIndexMap &in_map)
 Substract the weigthes from another index map from this one. More...
 
void DeferRefresh ()
 

Detailed Description

A map of weighted indecies. If a random index is selected, the probability of an index being returned is directly proportional to its weight.

Constructor & Destructor Documentation

emp::UnorderedIndexMap::UnorderedIndexMap ( size_t  _items = 0,
double  init_weight = 0.0 
)
inline

Construct an UnorderedIndexMap where num_items is the maximum number of items that can be placed into the data structure. All item weigths default to zero.

emp::UnorderedIndexMap::UnorderedIndexMap ( const UnorderedIndexMap )
default
emp::UnorderedIndexMap::UnorderedIndexMap ( UnorderedIndexMap &&  )
default
emp::UnorderedIndexMap::~UnorderedIndexMap ( )
default

Member Function Documentation

void emp::UnorderedIndexMap::Adjust ( size_t  id,
const double  new_weight 
)
inline
void emp::UnorderedIndexMap::Adjust ( const emp::vector< double > &  new_weights)
inline

Adjust all index weights to the set provided.

void emp::UnorderedIndexMap::AdjustAll ( double  new_weight)
inline

Adjust all index weights to the set provided.

void emp::UnorderedIndexMap::Clear ( )
inline

Reset all item weights to zero.

void emp::UnorderedIndexMap::DeferRefresh ( )
inline

Indicate that we need to adjust weights before relying on them in the future; this will prevent refreshes from occuring immediately and is useful when many updates to weights are likely to be done before any are accessed again.

double emp::UnorderedIndexMap::GetProb ( size_t  id) const
inline
size_t emp::UnorderedIndexMap::GetSize ( ) const
inline

How many indices are in this map?

double emp::UnorderedIndexMap::GetWeight ( ) const
inline

What is the total weight of all indices in this map?

double emp::UnorderedIndexMap::GetWeight ( size_t  id) const
inline
size_t emp::UnorderedIndexMap::Index ( double  index,
size_t  cur_id = 0 
) const
inline

Determine the ID at the specified index position.

UnorderedIndexMap& emp::UnorderedIndexMap::operator+= ( UnorderedIndexMap in_map)
inline

Add the weights in another index map to this one.

UnorderedIndexMap& emp::UnorderedIndexMap::operator-= ( UnorderedIndexMap in_map)
inline

Substract the weigthes from another index map from this one.

UnorderedIndexMap& emp::UnorderedIndexMap::operator= ( const UnorderedIndexMap )
default
UnorderedIndexMap& emp::UnorderedIndexMap::operator= ( UnorderedIndexMap &&  )
default
Proxy emp::UnorderedIndexMap::operator[] ( size_t  id)
inline

Index into a specified ID.

double emp::UnorderedIndexMap::operator[] ( size_t  id) const
inline
void emp::UnorderedIndexMap::RawAdjust ( size_t  id,
const double  new_weight 
)
inline

Adjust the weight associated with a particular index in the map.

Parameters
idis the identification number of the item whose weight is being adjusted.
weightis the new weight for that entry.
double emp::UnorderedIndexMap::RawProb ( size_t  id) const
inline

What is the probability of the specified index being selected?

double emp::UnorderedIndexMap::RawWeight ( size_t  id) const
inline

What is the current weight of the specified index?

void emp::UnorderedIndexMap::Resize ( size_t  new_size,
double  def_value = 0.0 
)
inline

Change the number of indecies in the map.

void emp::UnorderedIndexMap::resize ( size_t  new_size)
inline

Standard library compatibility.

void emp::UnorderedIndexMap::ResizeClear ( size_t  new_size)
inline

Change the size of this map AND change all weights to zero.

size_t emp::UnorderedIndexMap::size ( ) const
inline

Standard library compatibility.


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