mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
DynamicList changes
- setSize(const label)
* When the new size is greater than the addressed list size, the allocated
list sizes is adjusted and the addressed size does not change.
* Otherwise the addressed list size is just reduced and the allocated
size does not change. inline void setSize(const label);
- setSize(const label, const T&)
Disabled, since the usefulness and semantics are not quite clear
- operator=(const T&)
should not affect the allocated size (BUGFIX)
This commit is contained in:
@ -84,6 +84,11 @@ class DynamicList
|
|||||||
//- Allocated size for underlying List.
|
//- Allocated size for underlying List.
|
||||||
label allocSize_;
|
label allocSize_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
// Disabled, since the usefulness and semantics are not quite clear
|
||||||
|
void setSize(const label, const T&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Related types
|
// Related types
|
||||||
@ -117,20 +122,13 @@ public:
|
|||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Alter the list size.
|
//- Alter the list size.
|
||||||
// When the new size is greater than the addressed list size, both
|
// When the new size is greater than the addressed list size, the
|
||||||
// allocated and addressed list sizes are adjusted to the new size.
|
// allocated list sizes is adjusted and the
|
||||||
// Otherwise the addressed list size is just reduced and
|
// addressed size does not change.
|
||||||
// the allocated size does not change.
|
// Otherwise the addressed list size is just reduced and the
|
||||||
|
// allocated size does not change.
|
||||||
inline void setSize(const label);
|
inline void setSize(const label);
|
||||||
|
|
||||||
//- Alter the list size and assign a value for new elements.
|
|
||||||
// When the new size is greater than the addressed list size, both
|
|
||||||
// allocated and addressed list sizes are adjusted to the new size
|
|
||||||
// and a const value is assigned for the newly addressed elements.
|
|
||||||
// Otherwise the addressed list size is just reduced and
|
|
||||||
// the allocated size does not change.
|
|
||||||
inline void setSize(const label, const T&);
|
|
||||||
|
|
||||||
//- Clear the list, i.e. set the size to zero.
|
//- Clear the list, i.e. set the size to zero.
|
||||||
// Allocated size does not change
|
// Allocated size does not change
|
||||||
inline void clear();
|
inline void clear();
|
||||||
@ -164,7 +162,7 @@ public:
|
|||||||
// resizing the list if necessary
|
// resizing the list if necessary
|
||||||
inline T& operator()(const label);
|
inline T& operator()(const label);
|
||||||
|
|
||||||
//- Assignment of all entries to the given value
|
//- Assignment of all addressed entries to the given value
|
||||||
inline void operator=(const T&);
|
inline void operator=(const T&);
|
||||||
|
|
||||||
//- Assignment from List<T>. Also handles assignment from DynamicList.
|
//- Assignment from List<T>. Also handles assignment from DynamicList.
|
||||||
|
|||||||
@ -79,39 +79,19 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
|
|||||||
const label s
|
const label s
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (s <= List<T>::size())
|
label nextFree = List<T>::size();
|
||||||
|
if (s <= nextFree)
|
||||||
{
|
{
|
||||||
// adjust addressed size, leave allocated size untouched
|
// adjust addressed size, leave allocated size untouched
|
||||||
List<T>::size(s);
|
nextFree = s;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// adjust allocated and addressed sizes
|
// adjust allocated size, leave addressed size untouched
|
||||||
allocSize_ = s;
|
allocSize_ = s;
|
||||||
List<T>::setSize(allocSize_);
|
List<T>::setSize(allocSize_);
|
||||||
}
|
}
|
||||||
}
|
List<T>::size(nextFree);
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
|
|
||||||
(
|
|
||||||
const label s,
|
|
||||||
const T& t
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (s <= List<T>::size())
|
|
||||||
{
|
|
||||||
// adjust addressed size, leave allocated size untouched
|
|
||||||
List<T>::size(s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// adjust allocated and addressed sizes
|
|
||||||
// fill previously unused elements with constant value
|
|
||||||
allocSize_ = s;
|
|
||||||
List<T>::setSize(allocSize_, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -254,7 +234,6 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
List<T>::operator=(t);
|
List<T>::operator=(t);
|
||||||
allocSize_ = List<T>::size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user