Files
katrin-plasma/src/mc_electron/find_species.h
T

53 lines
1.0 KiB
C++

//
// find_species.h
// mc_electron
//
// Created by Christian Reiling on 03.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef find_species_h
#define find_species_h
#include <vector>
#include "particle.hpp"
template <typename T>
inline typename std::vector<T*>::iterator find_SpeciesItr(std::vector<T*> *Vec, species Species) {
typename std::vector<T*>::iterator Itr;
if (Vec->size() == 0) {
Itr = Vec->end();
} else {
Itr = Vec->begin();
while (Itr != Vec->end() ) {
if ((*Itr)->get_Species() == Species) {
break;
}
Itr++;
}
}
return (Itr);
}
template <typename T>
inline typename std::vector<T*>::const_iterator find_SpeciesConstItr(const std::vector<T*> *Vec, species Species) {
typename std::vector<T*>::const_iterator Itr;
if (Vec->size() == 0) {
Itr = Vec->cend();
} else {
Itr = Vec->cbegin();
while (Itr != Vec->cend() ) {
if ( (*Itr)->get_Species() == Species) {
break;
}
Itr++;
}
}
return (Itr);
}
#endif /* find_species_h */