Commit 0cfd019b authored by Mark OLESEN's avatar Mark OLESEN Committed by Andrew Heather
Browse files

STYLE: add data/cdata to VectorSpace for consistency with FixedList etc

parent c28d785a
......@@ -87,6 +87,25 @@ void testIterator(const VecSpace& vs)
}
template<class VecSpace>
void testData(const VecSpace& vs)
{
Info<< "size: " << vs.size() << " for:";
const auto* data = vs.cdata();
for
(
const auto* endData = data + VecSpace::nComponents;
data != endData;
++data
)
{
Info<< " " << *data;
}
Info<< nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
......@@ -105,6 +124,7 @@ int main(int argc, char *argv[])
testIterator(vec1);
testIterator(vec2);
testData(vec2);
// Use STL algorithm(s)
......
......@@ -178,6 +178,12 @@ public:
inline void component(Cmpt&, const direction) const;
inline void replace(const direction, const Cmpt&);
//- Return const pointer to the first data element
inline const Cmpt* cdata() const noexcept;
//- Return pointer to the first data element
inline Cmpt* data() noexcept;
//- Return a VectorSpace with all elements = s
inline static Form uniform(const Cmpt& s);
......@@ -213,7 +219,7 @@ public:
//- Return an iterator to begin of VectorSpace
inline iterator begin();
//- Return an iterator to end of UListVectorSpace
//- Return an iterator to end of VectorSpace
inline iterator end();
......
......@@ -193,6 +193,20 @@ Foam::VectorSpace<Form, Cmpt, Ncmpts>::block() const
// * * * * * * * * * * * * * * * * Iterator * * * * * * * * * * * * * * * * //
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::data() noexcept
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cdata() const noexcept
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment