Class NeighborsView¶
Non-allocating range over an agent's neighbors. More...
#include <agent-bones.hpp>
Classes¶
| Type | Name |
|---|---|
| class | iterator |
Public Functions¶
| Type | Name |
|---|---|
| NeighborsView () = default |
|
| NeighborsView (const size_t * first, size_t n, std::vector< Agent< TSeq > > * pop) |
|
| iterator | begin () const |
| bool | empty () const |
| iterator | end () const |
| size_t | size () const |
Detailed Description¶
Agent::get_neighbors() builds and returns a std::vector of pointers, which costs a heap allocation on every call and it is called once per susceptible agent per day, in the innermost loop of every state-update function. This view iterates the agent's neighbor ids in place and resolves each one against the model's population as it goes, so the same loop runs without allocating:
The order is the agent's neighbor order, identical to get_neighbors(). The view borrows from the agent and the model, so it must not outlive either, and it is invalidated by anything that changes the agent's ties.
Template parameters:
TSeqSequence type (should matchTSeqacross the model)
Public Functions Documentation¶
function NeighborsView [1/2]¶
function NeighborsView [2/2]¶
inline NeighborsView::NeighborsView (
const size_t * first,
size_t n,
std::vector< Agent < TSeq > > * pop
)
function begin¶
function empty¶
function end¶
function size¶
The documentation for this class was generated from the following file include/epiworld/agent-bones.hpp