Version: SMASH-1.5
smash::Particles::GenericIterator< T > Class Template Reference

#include <particles.h>

template<typename T>
class smash::Particles::GenericIterator< T >

Iterator type that skips over the holes in data_. It implements a standard bidirectional iterator over the ParticleData objects in Particles.

Definition at line 233 of file particles.h.

Inheritance diagram for smash::Particles::GenericIterator< T >:
[legend]
Collaboration diagram for smash::Particles::GenericIterator< T >:
[legend]

Public Types

using value_type = typename std::remove_const< T >::type
 remove const qualification More...
 
using pointer = typename std::add_pointer< T >::type
 provide the pointer of a reference More...
 
using reference = typename std::add_lvalue_reference< T >::type
 creates a lvalue reference More...
 
using const_pointer = typename std::add_const< pointer >::type
 add const qualification to a pointer More...
 
using const_reference = typename std::add_const< reference >::type
 add const qualification to a reference More...
 

Public Member Functions

GenericIteratoroperator++ ()
 Advance the iterator to the next valid (not a hole) entry in Particles. More...
 
GenericIterator operator++ (int)
 Postfix variant of the above prefix increment operator. More...
 
GenericIteratoroperator-- ()
 Advance the iterator to the previous valid (not a hole) entry in Particles. More...
 
GenericIterator operator-- (int)
 Postfix variant of the above prefix decrement operator. More...
 
reference operator* ()
 
const_reference operator* () const
 
pointer operator-> ()
 
const_pointer operator-> () const
 
bool operator== (const GenericIterator &rhs) const
 
bool operator!= (const GenericIterator &rhs) const
 
bool operator< (const GenericIterator &rhs) const
 
bool operator> (const GenericIterator &rhs) const
 
bool operator<= (const GenericIterator &rhs) const
 
bool operator>= (const GenericIterator &rhs) const
 

Private Member Functions

 GenericIterator (pointer p)
 Constructs an iterator pointing to the ParticleData pointed to by p. More...
 

Private Attributes

pointer ptr_
 The entry in Particles this iterator points to. More...
 

Friends

class Particles
 

Member Typedef Documentation

◆ value_type

template<typename T >
using smash::Particles::GenericIterator< T >::value_type = typename std::remove_const<T>::type

remove const qualification

Definition at line 239 of file particles.h.

◆ pointer

template<typename T >
using smash::Particles::GenericIterator< T >::pointer = typename std::add_pointer<T>::type

provide the pointer of a reference

Definition at line 241 of file particles.h.

◆ reference

template<typename T >
using smash::Particles::GenericIterator< T >::reference = typename std::add_lvalue_reference<T>::type

creates a lvalue reference

Definition at line 243 of file particles.h.

◆ const_pointer

template<typename T >
using smash::Particles::GenericIterator< T >::const_pointer = typename std::add_const<pointer>::type

add const qualification to a pointer

Definition at line 245 of file particles.h.

◆ const_reference

template<typename T >
using smash::Particles::GenericIterator< T >::const_reference = typename std::add_const<reference>::type

add const qualification to a reference

Definition at line 247 of file particles.h.

Constructor & Destructor Documentation

◆ GenericIterator()

template<typename T >
smash::Particles::GenericIterator< T >::GenericIterator ( pointer  p)
inlineprivate

Constructs an iterator pointing to the ParticleData pointed to by p.

This constructor may only be called from the Particles class.

Parameters
[in]pThe particle which is pointed by the iterator.

Definition at line 256 of file particles.h.

256 : ptr_(p) {} // NOLINT(runtime/explicit)
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259
constexpr int p
Proton.

Member Function Documentation

◆ operator++() [1/2]

template<typename T >
GenericIterator& smash::Particles::GenericIterator< T >::operator++ ( )
inline

Advance the iterator to the next valid (not a hole) entry in Particles.

Holes are identified by the ParticleData::hole_ member and thus the internal pointer is incremented until all holes are skipped. It is important that the Particles entry pointed to by Particles::end() is not identified as a hole as otherwise the iterator would advance too far.

Returns
the iterator to the next valid particle.

Definition at line 271 of file particles.h.

271  {
272  do {
273  ++ptr_;
274  } while (ptr_->hole_);
275  return *this;
276  }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259
Here is the caller graph for this function:

◆ operator++() [2/2]

template<typename T >
GenericIterator smash::Particles::GenericIterator< T >::operator++ ( int  )
inline

Postfix variant of the above prefix increment operator.

Returns
the iterator before increment.

Definition at line 282 of file particles.h.

282  {
283  GenericIterator old = *this;
284  operator++();
285  return old;
286  }
GenericIterator & operator++()
Advance the iterator to the next valid (not a hole) entry in Particles.
Definition: particles.h:271
GenericIterator(pointer p)
Constructs an iterator pointing to the ParticleData pointed to by p.
Definition: particles.h:256
Here is the call graph for this function:

◆ operator--() [1/2]

template<typename T >
GenericIterator& smash::Particles::GenericIterator< T >::operator-- ( )
inline

Advance the iterator to the previous valid (not a hole) entry in Particles.

Holes are identified by the ParticleData::hole_ member and thus the internal pointer is decremented until all holes are skipped. It is irrelevant whether Particles::data_[0] is a hole because the iteration typically ends at Particles::begin(), which points to a non-hole entry in Particles::data_.

Returns
the iterator to the previous valid particle.

Definition at line 299 of file particles.h.

299  {
300  do {
301  --ptr_;
302  } while (ptr_->hole_);
303  return *this;
304  }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259
Here is the caller graph for this function:

◆ operator--() [2/2]

template<typename T >
GenericIterator smash::Particles::GenericIterator< T >::operator-- ( int  )
inline

Postfix variant of the above prefix decrement operator.

Returns
the iterator before decrement.

Definition at line 310 of file particles.h.

310  {
311  GenericIterator old = *this;
312  operator--();
313  return old;
314  }
GenericIterator & operator--()
Advance the iterator to the previous valid (not a hole) entry in Particles.
Definition: particles.h:299
GenericIterator(pointer p)
Constructs an iterator pointing to the ParticleData pointed to by p.
Definition: particles.h:256
Here is the call graph for this function:

◆ operator*() [1/2]

template<typename T >
reference smash::Particles::GenericIterator< T >::operator* ( )
inline
Returns
the dereferenced iterator.

Definition at line 317 of file particles.h.

317 { return *ptr_; }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator*() [2/2]

template<typename T >
const_reference smash::Particles::GenericIterator< T >::operator* ( ) const
inline
Returns
the dereferenced iterator.

Definition at line 319 of file particles.h.

319 { return *ptr_; }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator->() [1/2]

template<typename T >
pointer smash::Particles::GenericIterator< T >::operator-> ( )
inline
Returns
the dereferenced iterator.

Definition at line 322 of file particles.h.

322 { return ptr_; }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator->() [2/2]

template<typename T >
const_pointer smash::Particles::GenericIterator< T >::operator-> ( ) const
inline
Returns
the dereferenced iterator.

Definition at line 324 of file particles.h.

324 { return ptr_; }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator==()

template<typename T >
bool smash::Particles::GenericIterator< T >::operator== ( const GenericIterator< T > &  rhs) const
inline
Returns
whether two iterators point to the same object.

Definition at line 327 of file particles.h.

327  {
328  return ptr_ == rhs.ptr_;
329  }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator!=()

template<typename T >
bool smash::Particles::GenericIterator< T >::operator!= ( const GenericIterator< T > &  rhs) const
inline
Returns
whether two iterators point to different objects.

Definition at line 331 of file particles.h.

331  {
332  return ptr_ != rhs.ptr_;
333  }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator<()

template<typename T >
bool smash::Particles::GenericIterator< T >::operator< ( const GenericIterator< T > &  rhs) const
inline
Returns
whether this iterator comes before the iterator rhs.

Definition at line 335 of file particles.h.

335 { return ptr_ < rhs.ptr_; }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator>()

template<typename T >
bool smash::Particles::GenericIterator< T >::operator> ( const GenericIterator< T > &  rhs) const
inline
Returns
whether this iterator comes after the iterator rhs.

Definition at line 337 of file particles.h.

337 { return ptr_ > rhs.ptr_; }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator<=()

template<typename T >
bool smash::Particles::GenericIterator< T >::operator<= ( const GenericIterator< T > &  rhs) const
inline
Returns
whether this iterator comes before the iterator rhs or points to the same object.

Definition at line 342 of file particles.h.

342  {
343  return ptr_ <= rhs.ptr_;
344  }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

◆ operator>=()

template<typename T >
bool smash::Particles::GenericIterator< T >::operator>= ( const GenericIterator< T > &  rhs) const
inline
Returns
whether this iterator comes after the iterator rhs or points to the same object.

Definition at line 349 of file particles.h.

349  {
350  return ptr_ >= rhs.ptr_;
351  }
pointer ptr_
The entry in Particles this iterator points to.
Definition: particles.h:259

Friends And Related Function Documentation

◆ Particles

template<typename T >
friend class Particles
friend

Definition at line 235 of file particles.h.

Member Data Documentation

◆ ptr_

template<typename T >
pointer smash::Particles::GenericIterator< T >::ptr_
private

The entry in Particles this iterator points to.

Definition at line 259 of file particles.h.


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