access to underlying list

This commit is contained in:
mattijs
2008-09-15 12:16:09 +01:00
parent a105eaf3ac
commit 4e17844699
2 changed files with 19 additions and 4 deletions

View File

@ -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

View File

@ -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