From 06edf6a113aa3c3597e55fd0600f260806570fbe Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Tue, 13 Feb 2024 19:09:59 +0100 Subject: [PATCH] rename Base/Util/VectorUtil.h -> Base/Util/Vec.h; + indexOfPtr --- Base/Util/{VectorUtil.h => Vec.h} | 22 +++++++++++++++------- Base/Util/VectorUtil.cpp | 15 --------------- 2 files changed, 15 insertions(+), 22 deletions(-) rename Base/Util/{VectorUtil.h => Vec.h} (57%) delete mode 100644 Base/Util/VectorUtil.cpp diff --git a/Base/Util/VectorUtil.h b/Base/Util/Vec.h similarity index 57% rename from Base/Util/VectorUtil.h rename to Base/Util/Vec.h index ea63efcbe99..7d34a481b3e 100644 --- a/Base/Util/VectorUtil.h +++ b/Base/Util/Vec.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file Base/Util/VectorUtil.h -//! @brief Defines namespace VectorUtil. +//! @file Base/Util/Vec.h +//! @brief Defines namespace Vec. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,13 +12,21 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_BASE_UTIL_VECTORUTIL_H -#define BORNAGAIN_BASE_UTIL_VECTORUTIL_H +#ifndef BORNAGAIN_BASE_UTIL_VEC_H +#define BORNAGAIN_BASE_UTIL_VEC_H #include <vector> -namespace VectorUtil { +namespace Vec { -} // namespace VectorUtil +template <class T, class S> int indexOfPtr(const T* t, const std::vector<S*>& v) +{ + for (size_t i = 0; i < v.size(); i++) + if (v[i] == t) + return int(i); + return -1; +} -#endif // BORNAGAIN_BASE_UTIL_VECTORUTIL_H +} // namespace Vec + +#endif // BORNAGAIN_BASE_UTIL_VEC_H diff --git a/Base/Util/VectorUtil.cpp b/Base/Util/VectorUtil.cpp deleted file mode 100644 index 75a94429d4a..00000000000 --- a/Base/Util/VectorUtil.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Base/Util/VectorUtil.cpp -//! @brief Implements namespace VectorUtil. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Base/Util/VectorUtil.h" -- GitLab