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 6 of file particles.cpp.

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

◆ begin() [2/2]

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

Definition at line 10 of file particles.cpp.

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

◆ end() [1/2]

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

Definition at line 14 of file particles.cpp.

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

◆ end() [2/2]

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

Definition at line 18 of file particles.cpp.

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

◆ size()

int Particles::size ( ) const

Get the number of particles.

Returns
int the number of particles

Definition at line 22 of file particles.cpp.

22 {
23 return particles.size();
24}
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 26 of file particles.cpp.

26 {
27 // This class assumes that the index of the inner vector is equal to the id of the particle located there.
28 // To ensure this, assert that the id of the particle is equal to the size of the inner vector.
29 assert(particle.id == particles.size());
30 particles.emplace_back(particle);
31}
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 33 of file particles.cpp.

33 {
34 return particles[index];
35}

◆ 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 37 of file particles.cpp.

37 {
38 return particles[index];
39}

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: