MPS-Basic
Loading...
Searching...
No Matches
Particles Class Reference

A collection of particles. More...

#include <particles.hpp>

Public Member Functions

std::vector< Particle >::iterator begin ()
 
std::vector< Particle >::const_iterator begin () const
 
std::vector< Particle >::iterator end ()
 
std::vector< Particle >::const_iterator end () const
 
int size () const
 Get the number of particles.
 
void add (const Particle &particle)
 Add a particle to the collection.
 
Particleoperator[] (size_t index)
 Get a particle by index.
 
const Particleoperator[] (size_t index) const
 Get a particle by index.
 

Private Attributes

std::vector< Particleparticles
 

Detailed Description

A collection of particles.

Definition at line 10 of file particles.hpp.

Member Function Documentation

◆ begin() [1/2]

std::vector< Particle >::iterator Particles::begin ( )

Definition at line 5 of file particles.cpp.

5 {
6 return particles.begin();
7}
std::vector< Particle > particles
Definition particles.hpp:49

◆ begin() [2/2]

std::vector< Particle >::const_iterator Particles::begin ( ) const

Definition at line 9 of file particles.cpp.

9 {
10 return particles.begin();
11}

◆ end() [1/2]

std::vector< Particle >::iterator Particles::end ( )

Definition at line 13 of file particles.cpp.

13 {
14 return particles.end();
15}

◆ end() [2/2]

std::vector< Particle >::const_iterator Particles::end ( ) const

Definition at line 17 of file particles.cpp.

17 {
18 return particles.end();
19}

◆ size()

int Particles::size ( ) const

Get the number of particles.

Returns
int the number of particles

Definition at line 21 of file particles.cpp.

21 {
22 return particles.size();
23}
Here is the caller graph for this function:

◆ add()

void Particles::add ( const Particle & particle)

Add a particle to the collection.

Parameters
particlethe particle to add

Definition at line 25 of file particles.cpp.

25 {
26 // This class assumes that the index of the inner vector is equal to the id of the particle located there.
27 // To ensure this, assert that the id of the particle is equal to the size of the inner vector.
28 assert(particle.id == particles.size());
29 particles.emplace_back(particle);
30}
int id
index of the particle
Definition particle.hpp:50
Here is the caller graph for this function:

◆ operator[]() [1/2]

Particle & Particles::operator[] ( size_t index)

Get a particle by index.

Parameters
indexthe index of the particle
Returns
Particle& the particle

Definition at line 32 of file particles.cpp.

32 {
33 return particles[index];
34}

◆ operator[]() [2/2]

const Particle & Particles::operator[] ( size_t index) const

Get a particle by index.

Parameters
indexthe index of the particle
Returns
const Particle& the particle

Definition at line 36 of file particles.cpp.

36 {
37 return particles[index];
38}

Member Data Documentation

◆ particles

std::vector<Particle> Particles::particles
private

Definition at line 49 of file particles.hpp.


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