Commit 4e178446 authored by mattijs's avatar mattijs
Browse files

access to underlying list

parent a105eaf3
......@@ -160,13 +160,15 @@ public:
//- Number of packed elements
inline label size() const;
//- Get value at index I
inline unsigned int get(const label i) const;
//- Set value at index I. Return true if value changed.
inline bool set(const label i, const unsigned int val);
//- Underlying storage
inline List<unsigned int>& storage();
// Member operators
......@@ -179,7 +181,8 @@ public:
//- Assignment operator. Takes linear time.
void operator=(const PackedList<nBits>&);
//- Assignment of all entries to the given value
//- Assignment of all entries to the given value. Does set on all
// elements.
inline void operator=(const unsigned int val);
//- Return as labelList
......
......@@ -83,7 +83,7 @@ inline void PackedList<nBits>::checkValue(const unsigned int val) const
{
if (val>=(1u << nBits))
{
FatalErrorIn("PackedList<T>::set(const unsigned int)")
FatalErrorIn("PackedList<T>::checkValue(const unsigned int)")
<< "value " << label(val) << " out of range 0 ... "
<< label((1u << nBits)-1)
<< " representable by " << nBits << " bits"
......@@ -183,6 +183,13 @@ inline bool PackedList<nBits>::set(const label i, const unsigned int val)
}
template<int nBits>
inline List<unsigned int>& PackedList<nBits>::storage()
{
return static_cast<List<unsigned int>&>(*this);
}
template<int nBits>
inline ::Foam::reference PackedList<nBits>::operator[](const label i)
{
......@@ -213,9 +220,14 @@ inline void PackedList<nBits>::operator=(const unsigned int val)
# ifdef DEBUGList
checkValue(val);
# endif
List<unsigned int>::operator=(val);
for (label i = 0; i < size; i++)
{
set(i, val);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
Markdown is supported
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