mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
List: Added construction from and assignment to zero
This commit is contained in:
@ -79,6 +79,30 @@ Foam::List<T>::List(const label s, const T& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
Foam::List<T>::List(const label s, const zero)
|
||||||
|
:
|
||||||
|
UList<T>(NULL, s)
|
||||||
|
{
|
||||||
|
if (this->size_ < 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "bad size " << this->size_
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->size_)
|
||||||
|
{
|
||||||
|
this->v_ = new T[this->size_];
|
||||||
|
|
||||||
|
List_ACCESS(T, (*this), vp);
|
||||||
|
List_FOR_ALL((*this), i)
|
||||||
|
List_ELEM((*this), vp, i) = Zero;
|
||||||
|
List_END_FOR_ALL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::List<T>::List(const List<T>& a)
|
Foam::List<T>::List(const List<T>& a)
|
||||||
:
|
:
|
||||||
|
|||||||
@ -105,6 +105,9 @@ public:
|
|||||||
//- Construct with given size and value for all elements.
|
//- Construct with given size and value for all elements.
|
||||||
List(const label, const T&);
|
List(const label, const T&);
|
||||||
|
|
||||||
|
//- Construct with given size initializing all elements to zero.
|
||||||
|
List(const label, const zero);
|
||||||
|
|
||||||
//- Copy constructor.
|
//- Copy constructor.
|
||||||
List(const List<T>&);
|
List(const List<T>&);
|
||||||
|
|
||||||
@ -225,6 +228,9 @@ public:
|
|||||||
//- Assignment of all entries to the given value
|
//- Assignment of all entries to the given value
|
||||||
inline void operator=(const T&);
|
inline void operator=(const T&);
|
||||||
|
|
||||||
|
//- Assignment of all entries to zero
|
||||||
|
inline void operator=(const zero);
|
||||||
|
|
||||||
|
|
||||||
// Istream operator
|
// Istream operator
|
||||||
|
|
||||||
|
|||||||
@ -141,4 +141,11 @@ inline void Foam::List<T>::operator=(const T& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::List<T>::operator=(const zero)
|
||||||
|
{
|
||||||
|
UList<T>::operator=(Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -76,6 +76,16 @@ void Foam::UList<T>::operator=(const T& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::UList<T>::operator=(const zero)
|
||||||
|
{
|
||||||
|
List_ACCESS(T, (*this), vp);
|
||||||
|
List_FOR_ALL((*this), i)
|
||||||
|
List_ELEM((*this), vp, i) = Zero;
|
||||||
|
List_END_FOR_ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@ -46,6 +46,7 @@ SourceFiles
|
|||||||
#include "label.H"
|
#include "label.H"
|
||||||
#include "uLabel.H"
|
#include "uLabel.H"
|
||||||
#include "nullObject.H"
|
#include "nullObject.H"
|
||||||
|
#include "zero.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -223,6 +224,9 @@ public:
|
|||||||
//- Assignment of all entries to the given value
|
//- Assignment of all entries to the given value
|
||||||
void operator=(const T&);
|
void operator=(const T&);
|
||||||
|
|
||||||
|
//- Assignment of all entries to zero
|
||||||
|
void operator=(const zero);
|
||||||
|
|
||||||
|
|
||||||
// STL type definitions
|
// STL type definitions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user