Skip to content
Snippets Groups Projects
Commit e1a57b15 authored by Philip Mueller, HS's avatar Philip Mueller, HS
Browse files

Added functions to construct a sample list from the other containers.

parent c93b079b
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,8 @@
#include <samples/yggdrasil_sample.hpp>
#include <samples/yggdrasil_dimensionArray.hpp>
#include <samples/yggdrasil_sampleList.hpp>
#include <samples/yggdrasil_arraySample.hpp>
#include <samples/yggdrasil_sampleCollection.hpp>
#include <samples/yggdrasil_matrixOrder.hpp>
#include <samples/yggdrasil_container_util.txx> //This is the helper code
......@@ -84,6 +86,73 @@ yggdrasil_sampleList_t::getColMatrix(
}; //End: getColMatrix
yggdrasil_sampleList_t::yggdrasil_sampleList_t(
const yggdrasil_arraySample_t& sArray)
:
yggdrasil_sampleList_t(sArray.nDims()) //Construct an empty container
{
//Load the parameter
const Size_t D = sArray.nDims();
const Size_t N = sArray.nSamples();
//Preallocate space for the insertion
this->reserve(N);
yggdrasil_assert(this->nSamples() == 0);
/*
* Iterate through the array and load the sample.
* We will then move them into the underling container.
*/
for(Size_t i = 0; i != N; ++i)
{
//load the sample
Sample_t s_i = sArray.getSample(i);
//Move the sample into the container
this->m_samples.push_back(std::move(s_i));
yggdrasil_assert(this->nSamples() == i);
}; //End for(i):
//Nw do not need D
(void)D;
}; //ENd: load from array
yggdrasil_sampleList_t::yggdrasil_sampleList_t(
const yggdrasil_sampleCollection_t& sCol)
:
yggdrasil_sampleList_t(sCol.nDims()) //Construct an empy container
{
//Load the parameter
const Size_t D = sCol.nDims();
const Size_t N = sCol.nSamples();
//Preallocate space for the insertion
this->reserve(N);
yggdrasil_assert(this->nSamples() == 0);
/*
* Iterate through the array and load the sample.
* We will then move them into the underling container.
*/
for(Size_t i = 0; i != N; ++i)
{
//load the sample
Sample_t s_i = sCol.getSample(i);
//Move the sample into the container
this->m_samples.push_back(std::move(s_i));
yggdrasil_assert(this->nSamples() == i);
}; //End for(i):
//Nw do not need D
(void)D;
}; //ENd: load from collection
template<class DimArr_t>
void
yggdrasil_sampleList_t::internal_setDimensionArray(
......
......@@ -26,6 +26,13 @@
YGGDRASIL_NS_START(yggdrasil)
//FWD of the Sample array class
class yggdrasil_arraySample_t;
//FWD of the sample collection type
class yggdrasil_sampleCollection_t;
/**
* \class yggdrasil_sampleList_t
* \brief Representation of many samples.
......@@ -221,6 +228,38 @@ public:
const yggdrasil_sampleList_t&) = default;
/**
* \brief This function performs a deep copy of sArray.
*
* This function loads the sample from the sample array sArray into *this.
* sArray is not modified.
* This allows the transformation of an sample array into a sample list.
*
* \param sArray The container to load from
*
* \throw If an error is detected.
*/
explicit
yggdrasil_sampleList_t(
const yggdrasil_arraySample_t& sArray);
/**
* \brief This function performs a deep copy of sColl.
*
* This functions loads the samples from the sample collection
* sCol and stores them in *this. sCol is not modified.
* This function allows to transform a collection into an array.
*
* \param sCol The collection ot load
*
* \throw If an error is detected.
*/
explicit
yggdrasil_sampleList_t(
const yggdrasil_sampleCollection_t& sCol);
/**
* \brief Move constructor.
*
......
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