From 0bbc24179a01ec0d9dd67676c69b029e972b4b2a Mon Sep 17 00:00:00 2001 From: Philip Mueller <philip.paul.mueller@bluemain.ch> Date: Sat, 17 Aug 2019 11:43:47 +0200 Subject: [PATCH] The dimensional array now supports an assign function. This function allows to set all elements of the array to a single value. --- code/cpp/samples/yggdrasil_dimensionArray.hpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/code/cpp/samples/yggdrasil_dimensionArray.hpp b/code/cpp/samples/yggdrasil_dimensionArray.hpp index 2dab4fcd..53e372c9 100644 --- a/code/cpp/samples/yggdrasil_dimensionArray.hpp +++ b/code/cpp/samples/yggdrasil_dimensionArray.hpp @@ -407,6 +407,32 @@ public: }; //End: operator[] (const) + /** + * \brief This function sets all values of *this to v. + * + * This function bypasses v to the assign function of the underlying container. + * There is no check performed on v. + * The only requirement is that *this is valid. + * All components of *this will afterwards be equal v. + * + * \param v The value we use for assigning. + */ + void + assign( + const Numeric_t v) + { + if(this->hasValidDimensions() == false) + { + throw YGGDRASIL_EXCEPT_RUNTIME("Tried to use an invalid dimension array for assigning."); + }; + + //Call the internal function for teh assigning + this->m_data.assign(this->m_data.size(), v); //Assign needs the size + + return; + }; //End assign + + /* * ================================== * Iterator access function -- GitLab