IAP GITLAB

Skip to content
Snippets Groups Projects
Commit f764e7ff authored by Antonio Augusto Alves Junior's avatar Antonio Augusto Alves Junior Committed by ralfulrich
Browse files

[refactory-2020] stack implementations: !290 headers

parent 2097ee69
No related branches found
No related tags found
No related merge requests found
...@@ -66,13 +66,13 @@ namespace corsika { ...@@ -66,13 +66,13 @@ namespace corsika {
} }
template <typename... Args1> template <typename... Args1>
void setParticleData(PI_C& p, const std::tuple<Args1...> vA) { void setParticleData(pi_a_type& p, const std::tuple<Args1...> vA) {
// static_assert(MT<I>::has_not, "error"); // static_assert(MT<I>::has_not, "error");
pi_a_type::setParticleData(static_cast<pi_a_type&>(p), vA); // original stack pi_a_type::setParticleData(static_cast<pi_a_type&>(p), vA); // original stack
pi_b_type::setParticleData(static_cast<pi_b_type&>(p)); // addon stack pi_b_type::setParticleData(static_cast<pi_b_type&>(p)); // addon stack
} }
template <typename... Args1, typename... Args2> template <typename... Args1, typename... Args2>
void setParticleData(PI_C& p, const std::tuple<Args1...> vA, const std::tuple<Args2...> vB) { void setParticleData(pi_c_type& p, const std::tuple<Args1...> vA, const std::tuple<Args2...> vB) {
pi_a_type::setParticleData(static_cast<pi_a_type&>(p), vA); pi_a_type::setParticleData(static_cast<pi_a_type&>(p), vA);
pi_b_type::setParticleData(static_cast<pi_b_type&>(p), vB); pi_b_type::setParticleData(static_cast<pi_b_type&>(p), vB);
...@@ -80,7 +80,7 @@ namespace corsika { ...@@ -80,7 +80,7 @@ namespace corsika {
///@} ///@}
std::string as_string() const { std::string as_string() const {
return fmt::format("[[{}][{}]]", PI_A::as_string(), pi_b_type::as_string()); return fmt::format("[[{}][{}]]", pi_a_type::as_string(), pi_b_type::as_string());
} }
private: private:
......
...@@ -549,4 +549,4 @@ namespace corsika { ...@@ -549,4 +549,4 @@ namespace corsika {
} // namespace corsika } // namespace corsika
#include <corsika/detail/framework/stack/SecondaryView.inl> //#include <corsika/detail/framework/stack/SecondaryView.inl>
...@@ -239,24 +239,24 @@ namespace corsika { ...@@ -239,24 +239,24 @@ namespace corsika {
*/ */
template <typename... TArgs> template <typename... TArgs>
stack_iterator_type addParticle(const TArgs... v) { stack_iterator_type addParticle(const TArgs... v) {
C8LOG_TRACE("Stack::AddParticle"); //C8LOG_TRACE("Stack::AddParticle");
data_.incrementSize(); data_.incrementSize();
deleted_.push_back(false); deleted_.push_back(false);
return stack_iterator_type(*this, getSize() - 1, v...); return stack_iterator_type(*this, getSize() - 1, v...);
} }
void swap(stack_iterator_type a, stack_iterator_type b) { void swap(stack_iterator_type a, stack_iterator_type b) {
C8LOG_TRACE("Stack::Swap"); //C8LOG_TRACE("Stack::Swap");
swap(a.getIndex(), b.getIndex()); swap(a.getIndex(), b.getIndex());
} }
void copy(stack_iterator_type a, stack_iterator_type b) { void copy(stack_iterator_type a, stack_iterator_type b) {
C8LOG_TRACE("Stack::Copy"); //C8LOG_TRACE("Stack::Copy");
copy(a.getIndex(), b.getIndex()); copy(a.getIndex(), b.getIndex());
} }
void copy(stack_iterator_type a, stack_iterator_type b) { void copy(const_stack_iterator_type a, stack_iterator_type b) {
C8LOG_TRACE("Stack::Copy"); //C8LOG_TRACE("Stack::Copy");
data_.copy(a.getIndex(), b.getIndex()); data_.copy(a.getIndex(), b.getIndex());
if (deleted_[b.getIndex()] && !deleted_[a.getIndex()]) nDeleted_--; if (deleted_[b.getIndex()] && !deleted_[a.getIndex()]) nDeleted_--;
if (!deleted_[b.getIndex()] && deleted_[a.getIndex()]) nDeleted_++; if (!deleted_[b.getIndex()] && deleted_[a.getIndex()]) nDeleted_++;
...@@ -264,7 +264,7 @@ namespace corsika { ...@@ -264,7 +264,7 @@ namespace corsika {
} }
void erase(stack_iterator_type p) { void erase(stack_iterator_type p) {
C8LOG_TRACE("Stack::Delete"); //C8LOG_TRACE("Stack::Delete");
if (this->isEmpty()) { /*error*/ if (this->isEmpty()) { /*error*/
throw std::runtime_error("Stack, cannot delete entry since size is zero"); throw std::runtime_error("Stack, cannot delete entry since size is zero");
} }
...@@ -276,7 +276,7 @@ namespace corsika { ...@@ -276,7 +276,7 @@ namespace corsika {
/** /**
* delete this particle * delete this particle
*/ */
void erase(ParticleInterfaceType p) { void erase(particle_interface_type p) {
this->erase(p.getIterator()); this->erase(p.getIterator());
} }
...@@ -295,11 +295,11 @@ namespace corsika { ...@@ -295,11 +295,11 @@ namespace corsika {
return isDeleted(p.getIndex()); return isDeleted(p.getIndex());
} }
bool isDeleted(const ConstStackIterator& p) const { bool isDeleted(const const_stack_iterator_type& p) const {
return isDeleted(p.getIndex()); return isDeleted(p.getIndex());
} }
bool isDeleted(const ParticleInterfaceType& p) const { bool isDeleted(const particle_interface_type& p) const {
return isDeleted(p.getIterator()); return isDeleted(p.getIterator());
} }
...@@ -311,7 +311,7 @@ namespace corsika { ...@@ -311,7 +311,7 @@ namespace corsika {
bool purgeLastIfDeleted() { bool purgeLastIfDeleted() {
if (!deleted_.back()) if (!deleted_.back())
return false; // the last particle is not marked for deletion. Do nothing. return false; // the last particle is not marked for deletion. Do nothing.
C8LOG_TRACE("Stack::purgeLastIfDeleted: yes"); //C8LOG_TRACE("Stack::purgeLastIfDeleted: yes");
data_.decrementSize(); data_.decrementSize();
nDeleted_--; nDeleted_--;
deleted_.pop_back(); deleted_.pop_back();
...@@ -371,19 +371,19 @@ namespace corsika { ...@@ -371,19 +371,19 @@ namespace corsika {
*/ */
template <typename... TArgs> template <typename... TArgs>
stack_iterator_type addSecondary(stack_iterator_type& parent, const TArgs... v) { stack_iterator_type addSecondary(stack_iterator_type& parent, const TArgs... v) {
C8LOG_TRACE("Stack::AddSecondary"); //C8LOG_TRACE("Stack::AddSecondary");
data_.incrementSize(); data_.incrementSize();
deleted_.push_back(false); deleted_.push_back(false);
return stack_iterator_type(*this, getSize() - 1, parent, v...); return stack_iterator_type(*this, getSize() - 1, parent, v...);
} }
void swap(unsigned int a, unsigned int b) { void swap(unsigned int a, unsigned int b) {
C8LOG_TRACE("Stack::Swap(unsigned int)"); //C8LOG_TRACE("Stack::Swap(unsigned int)");
data_.swap(a, b); data_.swap(a, b);
std::swap(deleted_[a], deleted_[b]); std::swap(deleted_[a], deleted_[b]);
} }
void copy(unsigned int a, unsigned int b) { void copy(unsigned int a, unsigned int b) {
C8LOG_TRACE("Stack::Copy"); //C8LOG_TRACE("Stack::Copy");
data_.copy(a, b); data_.copy(a, b);
if (deleted_[b] && !deleted_[a]) nDeleted_--; if (deleted_[b] && !deleted_[a]) nDeleted_--;
if (!deleted_[b] && deleted_[a]) nDeleted_++; if (!deleted_[b] && deleted_[a]) nDeleted_++;
...@@ -423,7 +423,7 @@ namespace corsika { ...@@ -423,7 +423,7 @@ namespace corsika {
* should just be identiy. See class SecondaryView for an alternative implementation. * should just be identiy. See class SecondaryView for an alternative implementation.
*/ */
unsigned int getIndexFromIterator(const unsigned int vI) const { unsigned int getIndexFromIterator(const unsigned int vI) const {
// this is too much: C8LOG_TRACE("Stack::getIndexFromIterator({})={}", vI, vI); // this is too much: //C8LOG_TRACE("Stack::getIndexFromIterator({})={}", vI, vI);
return vI; return vI;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment