From 4e17844699b53ff4f1f4aed791a1df1b29a26342 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 15 Sep 2008 12:16:09 +0100 Subject: [PATCH] access to underlying list --- .../containers/Lists/PackedList/PackedList.H | 7 +++++-- .../containers/Lists/PackedList/PackedListI.H | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index 8eb84b9749..5a966c6e68 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -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& storage(); + // Member operators @@ -179,7 +181,8 @@ public: //- Assignment operator. Takes linear time. void operator=(const PackedList&); - //- 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 diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H index 42b7afb81a..9cb2e6a29b 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H @@ -83,7 +83,7 @@ inline void PackedList::checkValue(const unsigned int val) const { if (val>=(1u << nBits)) { - FatalErrorIn("PackedList::set(const unsigned int)") + FatalErrorIn("PackedList::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::set(const label i, const unsigned int val) } +template +inline List& PackedList::storage() +{ + return static_cast&>(*this); +} + + template inline ::Foam::reference PackedList::operator[](const label i) { @@ -213,9 +220,14 @@ inline void PackedList::operator=(const unsigned int val) # ifdef DEBUGList checkValue(val); # endif - List::operator=(val); + + for (label i = 0; i < size; i++) + { + set(i, val); + } } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam