9#ifndef __POPULATIONS_H_INCLUDED__
10#define __POPULATIONS_H_INCLUDED__
13#include <unordered_map>
14#include <unordered_set>
31 std::unordered_map<Time, std::unordered_map<Space, Value>> m_populations;
35 using time_type =
Time;
37 using coord_type =
Space;
39 using value_type =
Value;
47 void set(coord_type
const &
x, time_type
const &t, value_type N)
50 m_populations[t][
x] = N;
55 value_type
get(coord_type
const &
x, time_type
const &t)
const
58 return m_populations.at(t).at(
x);
64 value_type
operator()(coord_type
const &
x, time_type
const &t)
const
73 value_type &
operator()(coord_type
const &
x, time_type
const &t)
75 return m_populations[t][
x];
82 std::vector<coord_type>
v;
83 for (
auto const &
it : m_populations.at(t))
87 v.push_back(
it.first);
96 bool is_defined(coord_type
const &
x, time_type
const &t)
const
98 return (!m_populations.empty()) && (m_populations.find(t) != m_populations.end()) &&
99 (m_populations.at(t).find(
x) != m_populations.at(t).end());
Population size distribution in time and space.
Definition PopulationSizeHashMapImplementation.hpp:30
value_type operator()(coord_type const &x, time_type const &t) const
Get population size at deme x at time t.
Definition PopulationSizeHashMapImplementation.hpp:64
PopulationSizeHashMapImplementation()=default
Default constructor.
bool is_defined(coord_type const &x, time_type const &t) const
Checks if population size is defined at deme x at time t.
Definition PopulationSizeHashMapImplementation.hpp:96
value_type & operator()(coord_type const &x, time_type const &t)
Population size at deme x at time t.
Definition PopulationSizeHashMapImplementation.hpp:73
std::vector< coord_type > definition_space(time_type const &t) const
Return the demes at which the population size was defined (>0) at time t.
Definition PopulationSizeHashMapImplementation.hpp:80
value_type get(coord_type const &x, time_type const &t) const
Get population size value at deme x at time t.
Definition PopulationSizeHashMapImplementation.hpp:55
void set(coord_type const &x, time_type const &t, value_type N)
Set population size value at deme x at time t.
Definition PopulationSizeHashMapImplementation.hpp:47
Simulation of coalescence-based models of molecular evolution.
Definition coalescence.hpp:21