7 #ifndef SRC_INCLUDE_PARTICLES_H_ 8 #define SRC_INCLUDE_PARTICLES_H_ 11 #include <type_traits> 157 void replace(
const ParticleList &to_remove, ParticleList &to_add);
178 assert(p.
type() == new_state.
type());
200 void update(
const ParticleList &old_state, ParticleList &new_state,
205 for (std::size_t i = 0; i < old_state.size(); ++i) {
232 template <
typename T>
234 :
public std::iterator<std::bidirectional_iterator_tag, T> {
241 using pointer =
typename std::add_pointer<T>::type;
243 using reference =
typename std::add_lvalue_reference<T>::type;
274 }
while (ptr_->hole_);
302 }
while (ptr_->hole_);
328 return ptr_ == rhs.
ptr_;
332 return ptr_ != rhs.
ptr_;
343 return ptr_ <= rhs.
ptr_;
350 return ptr_ >= rhs.
ptr_;
382 while (first->
hole_) {
394 while (first->
hole_) {
423 friend std::ostream &
operator<<(std::ostream &out,
483 std::unique_ptr<ParticleData[]>
data_;
494 #endif // SRC_INCLUDE_PARTICLES_H_ GenericIterator operator++(int)
Postfix variant of the above prefix increment operator.
void reset()
Reset the state of the Particles object to an empty list and a new id counter.
bool operator<(const GenericIterator &rhs) const
uint32_t id_process() const
Get the id of the last action.
const_iterator begin() const
const overload of begin()
std::vector< unsigned > dirty_
Stores the indexes in data_ that do not hold valid particle data and should be reused when new partic...
const ParticleData & lookup(const ParticleData &old_state) const
Returns the particle that is currently stored in this object given an old copy of that particle...
GenericIterator & operator--()
Advance the iterator to the previous valid (not a hole) entry in Particles.
typename std::remove_const< T >::type value_type
remove const qualification
bool operator<=(const GenericIterator &rhs) const
const_iterator end() const
const overload of end()
const FourVector & position() const
Get the particle's position in Minkowski space.
int id_max_
Highest id of a given particle.
const_iterator cend() const
typename std::add_const< reference >::type const_reference
add const qualification to a reference
void create(size_t n, PdgCode pdg)
Add n particles of the same type (pdg) to the list.
void ensure_capacity(unsigned to_add)
void copy_to(ParticleData &dst) const
Copies some information of the particle to the given particle dst.
const ParticleData & back() const
const overload of &back()
typename std::add_pointer< T >::type pointer
provide the pointer of a reference
void copy_in(ParticleData &to, const ParticleData &from)
std::unique_ptr< ParticleData[]> data_
Points to a dynamically allocated array of ParticleData objects.
ParticleList copy_to_vector() const
GenericIterator & operator++()
Advance the iterator to the next valid (not a hole) entry in Particles.
typename std::add_const< pointer >::type const_pointer
add const qualification to a pointer
Particles()
Creates a new (empty) Particles object.
void update(const ParticleList &old_state, ParticleList &new_state, bool do_replace)
Updates the Particles object, replacing the particles in old_state with the particles in new_state...
const ParticleData & update_particle(const ParticleData &p, const ParticleData &new_state)
Updates the particle identified by p with the state stored in new_state.
bool operator>=(const GenericIterator &rhs) const
const_pointer operator->() const
const_reference operator*() const
const_iterator cbegin() const
pointer ptr_
The entry in Particles this iterator points to.
GenericIterator operator--(int)
Postfix variant of the above prefix decrement operator.
bool hole_
If true, the object is an entry in Particles::data_ and does not hold valid particle data...
const ParticleData & insert(const ParticleData &p)
Inserts the particle into the list of particles.
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
bool operator==(const GenericIterator &rhs) const
const ParticleType & type() const
Get the type of the particle.
GenericIterator(pointer p)
Constructs an iterator pointing to the ParticleData pointed to by p.
typename std::add_lvalue_reference< T >::type reference
creates a lvalue reference
void replace(const ParticleList &to_remove, ParticleList &to_add)
Replace the particles in to_remove with the particles in to_add in the list of current particles...
double time() const
Returns the time of the computational frame.
unsigned index_
Internal index in the Particles list.
Particles & operator=(const Particles &)=delete
Cannot be copied.
bool operator>(const GenericIterator &rhs) const
friend std::ostream & operator<<(std::ostream &out, const Particles &particles)
Print effective mass and type name for all particles to the stream.
The Particles class abstracts the storage and manipulation of particles.
bool is_valid(const ParticleData ©) const
Check whether the ParticleData copy is still a valid copy of the one stored in the Particles object...
void increase_capacity(unsigned new_capacity)
int32_t id() const
Get the id of the particle.
ParticleData contains the dynamic information of a certain particle.
const ParticleData & front() const
const overload of &front()
bool operator!=(const GenericIterator &rhs) const