mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add bitSet-type of methods for boolList
- test(), get(), set(), unset() with behaviour as per bitSet, to allow easier swapping out of boolList <-> bitSet.
This commit is contained in:
@ -579,8 +579,7 @@ inline unsigned int Foam::PackedList<Width>::get(const label i) const
|
||||
}
|
||||
#endif
|
||||
|
||||
// Lazy evaluation - return 0 for out-of-range
|
||||
return 0u;
|
||||
return 0u; // Out-of-bounds (lazy): return 0 (false)
|
||||
}
|
||||
|
||||
return reference(const_cast<PackedList<Width>*>(this), i).get();
|
||||
@ -603,19 +602,16 @@ inline bool Foam::PackedList<Width>::set
|
||||
<< endl;
|
||||
#endif
|
||||
|
||||
// Lazy evaluation - ignore out-of-bounds
|
||||
return false;
|
||||
return false; // Out-of-bounds: ignore
|
||||
}
|
||||
else if (i >= size())
|
||||
{
|
||||
if (!val)
|
||||
if (!val) // Unset out-of-bounds: ignore
|
||||
{
|
||||
// Same as unset out-of-bounds = noop
|
||||
return false;
|
||||
}
|
||||
|
||||
// Lazy evaluation - increase size on assigment
|
||||
resize(i + 1);
|
||||
resize(i + 1); // Lazy evaluation: adjust size for assign
|
||||
}
|
||||
|
||||
return reference(this, i).set(val);
|
||||
@ -627,8 +623,7 @@ inline bool Foam::PackedList<Width>::unset(const label i)
|
||||
{
|
||||
if (i < 0 || i >= size())
|
||||
{
|
||||
// Unset out-of-bounds = noop
|
||||
return false;
|
||||
return false; // Unset out-of-bounds: ignore
|
||||
}
|
||||
|
||||
return reference(this, i).set(0u);
|
||||
|
||||
@ -35,330 +35,10 @@ License
|
||||
|
||||
#include <utility>
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const label len)
|
||||
:
|
||||
UList<T>(nullptr, len)
|
||||
{
|
||||
if (len < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad size " << len
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
alloc();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const label len, const T& val)
|
||||
:
|
||||
UList<T>(nullptr, len)
|
||||
{
|
||||
if (len < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad size " << len
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
alloc();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const label len, const zero)
|
||||
:
|
||||
UList<T>(nullptr, len)
|
||||
{
|
||||
if (len < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad size " << len
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
alloc();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const one, const T& val)
|
||||
:
|
||||
UList<T>(new T[1], 1)
|
||||
{
|
||||
this->v_[0] = val;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const one, T&& val)
|
||||
:
|
||||
UList<T>(new T[1], 1)
|
||||
{
|
||||
this->v_[0] = std::move(val);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const one, const zero)
|
||||
:
|
||||
UList<T>(new T[1], 1)
|
||||
{
|
||||
this->v_[0] = Zero;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UList<T>& a)
|
||||
:
|
||||
UList<T>(nullptr, a.size_)
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
alloc();
|
||||
|
||||
#ifdef USEMEMCPY
|
||||
if (contiguous<T>())
|
||||
{
|
||||
memcpy(this->v_, a.v_, this->byteSize());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_CONST_ACCESS(T, a, ap);
|
||||
List_FOR_ALL((*this), i)
|
||||
{
|
||||
vp[i] = ap[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const List<T>& a)
|
||||
:
|
||||
UList<T>(nullptr, a.size_)
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
alloc();
|
||||
|
||||
#ifdef USEMEMCPY
|
||||
if (contiguous<T>())
|
||||
{
|
||||
memcpy(this->v_, a.v_, this->byteSize());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_CONST_ACCESS(T, a, ap);
|
||||
List_FOR_ALL((*this), i)
|
||||
{
|
||||
vp[i] = ap[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(List<T>& a, bool reuse)
|
||||
:
|
||||
UList<T>(nullptr, a.size_)
|
||||
{
|
||||
if (reuse)
|
||||
{
|
||||
// swap content
|
||||
this->v_ = a.v_;
|
||||
a.v_ = nullptr;
|
||||
a.size_ = 0;
|
||||
}
|
||||
else if (this->size_)
|
||||
{
|
||||
alloc();
|
||||
|
||||
#ifdef USEMEMCPY
|
||||
if (contiguous<T>())
|
||||
{
|
||||
memcpy(this->v_, a.v_, this->byteSize());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_CONST_ACCESS(T, a, ap);
|
||||
List_FOR_ALL((*this), i)
|
||||
{
|
||||
vp[i] = ap[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UList<T>& lst, const labelUList& mapAddressing)
|
||||
:
|
||||
UList<T>(nullptr, mapAddressing.size())
|
||||
{
|
||||
const label len = mapAddressing.size();
|
||||
|
||||
if (len)
|
||||
{
|
||||
alloc();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = lst[mapAddressing[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class InputIterator>
|
||||
Foam::List<T>::List(InputIterator begIter, InputIterator endIter)
|
||||
:
|
||||
List<T>(begIter, endIter, std::distance(begIter, endIter))
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<unsigned Size>
|
||||
Foam::List<T>::List(const FixedList<T, Size>& lst)
|
||||
:
|
||||
UList<T>(nullptr, Size)
|
||||
{
|
||||
alloc();
|
||||
copyList(lst);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const PtrList<T>& lst)
|
||||
:
|
||||
UList<T>(nullptr, lst.size())
|
||||
{
|
||||
alloc();
|
||||
copyList(lst);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const SLList<T>& lst)
|
||||
:
|
||||
List<T>(lst.begin(), lst.end(), lst.size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UIndirectList<T>& lst)
|
||||
:
|
||||
UList<T>(nullptr, lst.size())
|
||||
{
|
||||
alloc();
|
||||
copyList(lst);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const BiIndirectList<T>& lst)
|
||||
:
|
||||
UList<T>(nullptr, lst.size())
|
||||
{
|
||||
alloc();
|
||||
copyList(lst);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(std::initializer_list<T> lst)
|
||||
:
|
||||
List<T>(lst.begin(), lst.end(), lst.size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(List<T>&& lst)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
// Can use transfer or swap to manage content
|
||||
transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<int SizeMin>
|
||||
Foam::List<T>::List(DynamicList<T, SizeMin>&& lst)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(SortableList<T>&& lst)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(SLList<T>&& lst)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
operator=(std::move(lst));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::~List()
|
||||
{
|
||||
if (this->v_)
|
||||
{
|
||||
delete[] this->v_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::setSize(const label newSize)
|
||||
void Foam::List<T>::doResize(const label newSize)
|
||||
{
|
||||
if (newSize < 0)
|
||||
{
|
||||
@ -406,11 +86,333 @@ void Foam::List<T>::setSize(const label newSize)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::setSize(const label newSize, const T& val)
|
||||
Foam::List<T>::List(const label len)
|
||||
:
|
||||
UList<T>(nullptr, len)
|
||||
{
|
||||
if (len < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad size " << len
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
doAlloc();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const label len, const T& val)
|
||||
:
|
||||
UList<T>(nullptr, len)
|
||||
{
|
||||
if (len < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad size " << len
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const label len, const zero)
|
||||
:
|
||||
UList<T>(nullptr, len)
|
||||
{
|
||||
if (len < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad size " << len
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const one, const T& val)
|
||||
:
|
||||
UList<T>(new T[1], 1)
|
||||
{
|
||||
this->v_[0] = val;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const one, T&& val)
|
||||
:
|
||||
UList<T>(new T[1], 1)
|
||||
{
|
||||
this->v_[0] = std::move(val);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const one, const zero)
|
||||
:
|
||||
UList<T>(new T[1], 1)
|
||||
{
|
||||
this->v_[0] = Zero;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UList<T>& a)
|
||||
:
|
||||
UList<T>(nullptr, a.size_)
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
#ifdef USEMEMCPY
|
||||
if (contiguous<T>())
|
||||
{
|
||||
memcpy(this->v_, a.v_, this->byteSize());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_CONST_ACCESS(T, a, ap);
|
||||
List_FOR_ALL((*this), i)
|
||||
{
|
||||
vp[i] = ap[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const List<T>& a)
|
||||
:
|
||||
UList<T>(nullptr, a.size_)
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
#ifdef USEMEMCPY
|
||||
if (contiguous<T>())
|
||||
{
|
||||
memcpy(this->v_, a.v_, this->byteSize());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_CONST_ACCESS(T, a, ap);
|
||||
List_FOR_ALL((*this), i)
|
||||
{
|
||||
vp[i] = ap[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(List<T>& a, bool reuse)
|
||||
:
|
||||
UList<T>(nullptr, a.size_)
|
||||
{
|
||||
if (reuse)
|
||||
{
|
||||
// swap content
|
||||
this->v_ = a.v_;
|
||||
a.v_ = nullptr;
|
||||
a.size_ = 0;
|
||||
}
|
||||
else if (this->size_)
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
#ifdef USEMEMCPY
|
||||
if (contiguous<T>())
|
||||
{
|
||||
memcpy(this->v_, a.v_, this->byteSize());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_CONST_ACCESS(T, a, ap);
|
||||
List_FOR_ALL((*this), i)
|
||||
{
|
||||
vp[i] = ap[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UList<T>& list, const labelUList& mapAddressing)
|
||||
:
|
||||
UList<T>(nullptr, mapAddressing.size())
|
||||
{
|
||||
const label len = mapAddressing.size();
|
||||
|
||||
if (len)
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = list[mapAddressing[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class InputIterator>
|
||||
Foam::List<T>::List(InputIterator begIter, InputIterator endIter)
|
||||
:
|
||||
List<T>(begIter, endIter, std::distance(begIter, endIter))
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<unsigned Size>
|
||||
Foam::List<T>::List(const FixedList<T, Size>& list)
|
||||
:
|
||||
UList<T>(nullptr, Size)
|
||||
{
|
||||
doAlloc();
|
||||
copyList(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const PtrList<T>& list)
|
||||
:
|
||||
UList<T>(nullptr, list.size())
|
||||
{
|
||||
doAlloc();
|
||||
copyList(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const SLList<T>& list)
|
||||
:
|
||||
List<T>(list.begin(), list.end(), list.size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UIndirectList<T>& list)
|
||||
:
|
||||
UList<T>(nullptr, list.size())
|
||||
{
|
||||
doAlloc();
|
||||
copyList(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const BiIndirectList<T>& list)
|
||||
:
|
||||
UList<T>(nullptr, list.size())
|
||||
{
|
||||
doAlloc();
|
||||
copyList(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(std::initializer_list<T> list)
|
||||
:
|
||||
List<T>(list.begin(), list.end(), list.size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(List<T>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
// Can use transfer or swap to manage content
|
||||
transfer(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<int SizeMin>
|
||||
Foam::List<T>::List(DynamicList<T, SizeMin>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
transfer(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(SortableList<T>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
transfer(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(SLList<T>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
operator=(std::move(list));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::~List()
|
||||
{
|
||||
if (this->v_)
|
||||
{
|
||||
delete[] this->v_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::resize(const label newSize, const T& val)
|
||||
{
|
||||
const label oldSize = this->size_;
|
||||
this->setSize(newSize);
|
||||
this->doResize(newSize);
|
||||
|
||||
List_ACCESS(T, *this, vp);
|
||||
for (label i = oldSize; i < newSize; ++i)
|
||||
@ -421,37 +423,37 @@ void Foam::List<T>::setSize(const label newSize, const T& val)
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::transfer(List<T>& lst)
|
||||
void Foam::List<T>::transfer(List<T>& list)
|
||||
{
|
||||
// Clear and swap - could also check for self assignment
|
||||
clear();
|
||||
this->size_ = lst.size_;
|
||||
this->v_ = lst.v_;
|
||||
this->size_ = list.size_;
|
||||
this->v_ = list.v_;
|
||||
|
||||
lst.size_ = 0;
|
||||
lst.v_ = nullptr;
|
||||
list.size_ = 0;
|
||||
list.v_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<int SizeMin>
|
||||
void Foam::List<T>::transfer(DynamicList<T, SizeMin>& lst)
|
||||
void Foam::List<T>::transfer(DynamicList<T, SizeMin>& list)
|
||||
{
|
||||
// Shrink the allocated space to the number of elements used
|
||||
lst.shrink();
|
||||
transfer(static_cast<List<T>&>(lst));
|
||||
list.shrink();
|
||||
transfer(static_cast<List<T>&>(list));
|
||||
|
||||
// Ensure DynamicList has proper capacity=0 too
|
||||
lst.clearStorage();
|
||||
list.clearStorage();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::transfer(SortableList<T>& lst)
|
||||
void Foam::List<T>::transfer(SortableList<T>& list)
|
||||
{
|
||||
// Shrink away the sort indices
|
||||
lst.shrink();
|
||||
transfer(static_cast<List<T>&>(lst));
|
||||
list.shrink();
|
||||
transfer(static_cast<List<T>&>(list));
|
||||
}
|
||||
|
||||
|
||||
@ -484,23 +486,23 @@ void Foam::List<T>::operator=(const UList<T>& a)
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(const List<T>& lst)
|
||||
void Foam::List<T>::operator=(const List<T>& list)
|
||||
{
|
||||
if (this == &lst)
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
operator=(static_cast<const UList<T>&>(lst));
|
||||
operator=(static_cast<const UList<T>&>(list));
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(const SLList<T>& lst)
|
||||
void Foam::List<T>::operator=(const SLList<T>& list)
|
||||
{
|
||||
const label len = lst.size();
|
||||
const label len = list.size();
|
||||
|
||||
reAlloc(len);
|
||||
|
||||
@ -509,7 +511,7 @@ void Foam::List<T>::operator=(const SLList<T>& lst)
|
||||
List_ACCESS(T, (*this), vp);
|
||||
|
||||
label i = 0;
|
||||
for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
|
||||
for (auto iter = list.cbegin(); iter != list.cend(); ++iter)
|
||||
{
|
||||
vp[i] = *iter;
|
||||
++i;
|
||||
@ -519,9 +521,9 @@ void Foam::List<T>::operator=(const SLList<T>& lst)
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(const UIndirectList<T>& lst)
|
||||
void Foam::List<T>::operator=(const UIndirectList<T>& list)
|
||||
{
|
||||
const label len = lst.size();
|
||||
const label len = list.size();
|
||||
|
||||
reAlloc(len);
|
||||
|
||||
@ -531,16 +533,16 @@ void Foam::List<T>::operator=(const UIndirectList<T>& lst)
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
vp[i] = lst[i];
|
||||
vp[i] = list[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(const BiIndirectList<T>& lst)
|
||||
void Foam::List<T>::operator=(const BiIndirectList<T>& list)
|
||||
{
|
||||
const label len = lst.size();
|
||||
const label len = list.size();
|
||||
|
||||
reAlloc(len);
|
||||
|
||||
@ -550,16 +552,16 @@ void Foam::List<T>::operator=(const BiIndirectList<T>& lst)
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
vp[i] = lst[i];
|
||||
vp[i] = list[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(std::initializer_list<T> lst)
|
||||
void Foam::List<T>::operator=(std::initializer_list<T> list)
|
||||
{
|
||||
const label len = lst.size();
|
||||
const label len = list.size();
|
||||
|
||||
reAlloc(len);
|
||||
|
||||
@ -568,7 +570,7 @@ void Foam::List<T>::operator=(std::initializer_list<T> lst)
|
||||
List_ACCESS(T, (*this), vp);
|
||||
|
||||
label i = 0;
|
||||
for (const auto& val : lst)
|
||||
for (const auto& val : list)
|
||||
{
|
||||
vp[i] = val;
|
||||
++i;
|
||||
@ -578,38 +580,38 @@ void Foam::List<T>::operator=(std::initializer_list<T> lst)
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(List<T>&& lst)
|
||||
void Foam::List<T>::operator=(List<T>&& list)
|
||||
{
|
||||
if (this == &lst)
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
transfer(lst);
|
||||
transfer(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<int SizeMin>
|
||||
void Foam::List<T>::operator=(DynamicList<T, SizeMin>&& lst)
|
||||
void Foam::List<T>::operator=(DynamicList<T, SizeMin>&& list)
|
||||
{
|
||||
transfer(lst);
|
||||
transfer(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(SortableList<T>&& lst)
|
||||
void Foam::List<T>::operator=(SortableList<T>&& list)
|
||||
{
|
||||
transfer(lst);
|
||||
transfer(list);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(SLList<T>&& lst)
|
||||
void Foam::List<T>::operator=(SLList<T>&& list)
|
||||
{
|
||||
const label len = lst.size();
|
||||
const label len = list.size();
|
||||
|
||||
reAlloc(len);
|
||||
|
||||
@ -619,11 +621,11 @@ void Foam::List<T>::operator=(SLList<T>&& lst)
|
||||
|
||||
for (label i = 0; i < len; ++i)
|
||||
{
|
||||
vp[i] = std::move(lst.removeHead());
|
||||
vp[i] = std::move(list.removeHead());
|
||||
}
|
||||
}
|
||||
|
||||
lst.clear();
|
||||
list.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ template<class T> class IndirectList;
|
||||
template<class T> class UIndirectList;
|
||||
template<class T> class BiIndirectList;
|
||||
|
||||
template<class T> Istream& operator>>(Istream& is, List<T>& L);
|
||||
template<class T> Istream& operator>>(Istream& is, List<T>& list);
|
||||
|
||||
// Commonly required list types
|
||||
typedef List<char> charList;
|
||||
@ -82,17 +82,20 @@ class List
|
||||
:
|
||||
public UList<T>
|
||||
{
|
||||
// Private member functions
|
||||
// Private Member Functions
|
||||
|
||||
//- Allocate list storage
|
||||
inline void alloc();
|
||||
inline void doAlloc();
|
||||
|
||||
//- Reallocate list storage to the given size
|
||||
inline void reAlloc(const label len);
|
||||
|
||||
//- Copy list of given type.
|
||||
template<class List2>
|
||||
inline void copyList(const List2& lst);
|
||||
inline void copyList(const List2& list);
|
||||
|
||||
//- Change allocation size of List. Backend for resize/setSize.
|
||||
void doResize(const label newSize);
|
||||
|
||||
//- Construct given begin/end iterators and number of elements
|
||||
// Since the size is provided, the end iterator is actually ignored.
|
||||
@ -146,7 +149,7 @@ public:
|
||||
List(List<T>& a, bool reuse);
|
||||
|
||||
//- Construct as subset
|
||||
List(const UList<T>& lst, const labelUList& mapAddressing);
|
||||
List(const UList<T>& list, const labelUList& mapAddressing);
|
||||
|
||||
//- Construct given begin/end iterators.
|
||||
// Uses std::distance for the size.
|
||||
@ -155,35 +158,35 @@ public:
|
||||
|
||||
//- Construct as copy of FixedList<T, Size>
|
||||
template<unsigned Size>
|
||||
explicit List(const FixedList<T, Size>& lst);
|
||||
explicit List(const FixedList<T, Size>& list);
|
||||
|
||||
//- Construct as copy of PtrList<T>
|
||||
explicit List(const PtrList<T>& lst);
|
||||
explicit List(const PtrList<T>& list);
|
||||
|
||||
//- Construct as copy of SLList<T>
|
||||
explicit List(const SLList<T>& lst);
|
||||
explicit List(const SLList<T>& list);
|
||||
|
||||
//- Construct as copy of UIndirectList<T>
|
||||
explicit List(const UIndirectList<T>& lst);
|
||||
explicit List(const UIndirectList<T>& list);
|
||||
|
||||
//- Construct as copy of BiIndirectList<T>
|
||||
explicit List(const BiIndirectList<T>& lst);
|
||||
explicit List(const BiIndirectList<T>& list);
|
||||
|
||||
//- Construct from an initializer list
|
||||
List(std::initializer_list<T> lst);
|
||||
List(std::initializer_list<T> list);
|
||||
|
||||
//- Move construct from List
|
||||
List(List<T>&& lst);
|
||||
List(List<T>&& list);
|
||||
|
||||
//- Move construct from DynamicList
|
||||
template<int SizeMin>
|
||||
List(DynamicList<T, SizeMin>&& lst);
|
||||
List(DynamicList<T, SizeMin>&& list);
|
||||
|
||||
//- Move construct from SortableList
|
||||
List(SortableList<T>&& lst);
|
||||
List(SortableList<T>&& list);
|
||||
|
||||
//- Move construct from SLList
|
||||
List(SLList<T>&& lst);
|
||||
List(SLList<T>&& list);
|
||||
|
||||
//- Construct from Istream
|
||||
List(Istream& is);
|
||||
@ -206,17 +209,18 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Alias for setSize(const label)
|
||||
//- Adjust allocated size of list.
|
||||
// The boolList version fills new memory with false.
|
||||
inline void resize(const label newSize);
|
||||
|
||||
//- Alias for setSize(const label, const T&)
|
||||
inline void resize(const label newSize, const T& val);
|
||||
//- Adjust allocated size of list and set val for new elements
|
||||
void resize(const label newSize, const T& val);
|
||||
|
||||
//- Reset size of List
|
||||
void setSize(const label newSize);
|
||||
//- Alias for resize(const label)
|
||||
inline void setSize(const label newSize);
|
||||
|
||||
//- Reset size of List and value for new elements
|
||||
void setSize(const label newSize, const T& val);
|
||||
//- Alias for resize(const label, const T&)
|
||||
inline void setSize(const label newSize, const T& val);
|
||||
|
||||
//- Clear the list, i.e. set size to zero
|
||||
inline void clear();
|
||||
@ -228,23 +232,23 @@ public:
|
||||
inline void append(T&& val);
|
||||
|
||||
//- Append a List to the end of this list
|
||||
inline void append(const UList<T>& lst);
|
||||
inline void append(const UList<T>& list);
|
||||
|
||||
//- Append a UIndirectList at the end of this list
|
||||
inline void append(const UIndirectList<T>& lst);
|
||||
inline void append(const UIndirectList<T>& list);
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
//- and annul the argument list
|
||||
void transfer(List<T>& lst);
|
||||
void transfer(List<T>& list);
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
//- and annul the argument list
|
||||
template<int SizeMin>
|
||||
void transfer(DynamicList<T, SizeMin>& lst);
|
||||
void transfer(DynamicList<T, SizeMin>& list);
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
//- and annul the argument list
|
||||
void transfer(SortableList<T>& lst);
|
||||
void transfer(SortableList<T>& list);
|
||||
|
||||
//- Return subscript-checked element of UList and resizing the list
|
||||
//- if required.
|
||||
@ -257,19 +261,19 @@ public:
|
||||
void operator=(const UList<T>& a);
|
||||
|
||||
//- Assignment operator. Takes linear time
|
||||
void operator=(const List<T>& lst);
|
||||
void operator=(const List<T>& list);
|
||||
|
||||
//- Assignment to SLList operator. Takes linear time
|
||||
void operator=(const SLList<T>& lst);
|
||||
void operator=(const SLList<T>& list);
|
||||
|
||||
//- Assignment to UIndirectList operator. Takes linear time
|
||||
void operator=(const UIndirectList<T>& lst);
|
||||
void operator=(const UIndirectList<T>& list);
|
||||
|
||||
//- Assignment to BiIndirectList operator. Takes linear time
|
||||
void operator=(const BiIndirectList<T>& lst);
|
||||
void operator=(const BiIndirectList<T>& list);
|
||||
|
||||
//- Assignment to an initializer list
|
||||
void operator=(std::initializer_list<T> lst);
|
||||
void operator=(std::initializer_list<T> list);
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T& val);
|
||||
@ -278,17 +282,17 @@ public:
|
||||
inline void operator=(const zero);
|
||||
|
||||
//- Move assignment. Takes constant time
|
||||
void operator=(List<T>&& lst);
|
||||
void operator=(List<T>&& list);
|
||||
|
||||
//- Move assignment. Takes constant time.
|
||||
template<int SizeMin>
|
||||
void operator=(DynamicList<T, SizeMin>&& lst);
|
||||
void operator=(DynamicList<T, SizeMin>&& list);
|
||||
|
||||
//- Move assignment. Takes constant time.
|
||||
void operator=(SortableList<T>&& lst);
|
||||
void operator=(SortableList<T>&& list);
|
||||
|
||||
//- Move assignment. Takes constant time
|
||||
void operator=(SLList<T>&& lst);
|
||||
void operator=(SLList<T>&& list);
|
||||
|
||||
|
||||
// Istream Operator
|
||||
@ -297,7 +301,7 @@ public:
|
||||
friend Istream& operator>> <T>
|
||||
(
|
||||
Istream& is,
|
||||
List<T>& L
|
||||
List<T>& list
|
||||
);
|
||||
|
||||
|
||||
@ -305,6 +309,34 @@ public:
|
||||
|
||||
//- No shallowCopy permitted
|
||||
void shallowCopy(const UList<T>&) = delete;
|
||||
|
||||
|
||||
// Special Methods
|
||||
|
||||
//- A bitSet::set() method for a list of bool
|
||||
// Increases size when setting an out-of-bounds value.
|
||||
//
|
||||
// \return True if value changed.
|
||||
template<class TypeT = T>
|
||||
typename std::enable_if<std::is_same<TypeT, bool>::value, bool>::type
|
||||
inline set(const label i, bool val = true)
|
||||
{
|
||||
if (i < 0)
|
||||
{
|
||||
return false; // Out-of-bounds: ignore
|
||||
}
|
||||
else if (i >= this->size())
|
||||
{
|
||||
if (!val) // Unset out-of-bounds: ignore
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this->resize(i+1, false); // Adjust size for assign, fill 0
|
||||
}
|
||||
|
||||
(*this)[i] = val;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::alloc()
|
||||
inline void Foam::List<T>::doAlloc()
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
@ -42,20 +42,20 @@ inline void Foam::List<T>::reAlloc(const label len)
|
||||
{
|
||||
clear();
|
||||
this->size_ = len;
|
||||
alloc();
|
||||
doAlloc();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class List2>
|
||||
inline void Foam::List<T>::copyList(const List2& lst)
|
||||
inline void Foam::List<T>::copyList(const List2& list)
|
||||
{
|
||||
const label len = this->size_;
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
this->operator[](i) = lst[i];
|
||||
this->operator[](i) = list[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ inline Foam::List<T>::List
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
alloc();
|
||||
doAlloc();
|
||||
|
||||
InputIterator iter = begIter;
|
||||
for (label i = 0; i < len; ++i)
|
||||
@ -121,17 +121,35 @@ inline void Foam::List<T>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::resize(const label len)
|
||||
namespace Foam
|
||||
{
|
||||
this->setSize(len);
|
||||
// Template specialization for bool. Fills with false
|
||||
template<>
|
||||
inline void List<bool>::resize(const label newSize)
|
||||
{
|
||||
this->resize(newSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::resize(const label len, const T& val)
|
||||
inline void Foam::List<T>::resize(const label len)
|
||||
{
|
||||
this->setSize(len, val);
|
||||
this->doResize(len);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::setSize(const label len)
|
||||
{
|
||||
this->resize(len);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::setSize(const label len, const T& val)
|
||||
{
|
||||
this->resize(len, val);
|
||||
}
|
||||
|
||||
|
||||
@ -142,7 +160,7 @@ inline T& Foam::List<T>::newElmt(const label i)
|
||||
|
||||
if (i >= n)
|
||||
{
|
||||
setSize(2*n);
|
||||
resize(2*n);
|
||||
}
|
||||
|
||||
return UList<T>::operator[](i);
|
||||
@ -152,7 +170,7 @@ inline T& Foam::List<T>::newElmt(const label i)
|
||||
template<class T>
|
||||
inline void Foam::List<T>::append(const T& val)
|
||||
{
|
||||
setSize(this->size() + 1, val); // copy element
|
||||
resize(this->size() + 1, val); // copy element
|
||||
}
|
||||
|
||||
|
||||
@ -160,44 +178,44 @@ template<class T>
|
||||
inline void Foam::List<T>::append(T&& val)
|
||||
{
|
||||
const label idx = this->size();
|
||||
setSize(idx + 1);
|
||||
resize(idx + 1);
|
||||
|
||||
this->operator[](idx) = std::move(val); // move assign element
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::append(const UList<T>& lst)
|
||||
inline void Foam::List<T>::append(const UList<T>& list)
|
||||
{
|
||||
if (this == &lst)
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "attempted appending to self" << abort(FatalError);
|
||||
}
|
||||
|
||||
label idx = this->size();
|
||||
const label n = lst.size();
|
||||
const label n = list.size();
|
||||
|
||||
setSize(idx + n);
|
||||
resize(idx + n);
|
||||
|
||||
for (label i=0; i<n; ++i)
|
||||
{
|
||||
this->operator[](idx++) = lst[i]; // copy element
|
||||
this->operator[](idx++) = list[i]; // copy element
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::append(const UIndirectList<T>& lst)
|
||||
inline void Foam::List<T>::append(const UIndirectList<T>& list)
|
||||
{
|
||||
label idx = this->size();
|
||||
const label n = lst.size();
|
||||
const label n = list.size();
|
||||
|
||||
setSize(idx + n);
|
||||
resize(idx + n);
|
||||
|
||||
for (label i=0; i<n; ++i)
|
||||
{
|
||||
this->operator[](idx++) = lst[i]; // copy element
|
||||
this->operator[](idx++) = list[i]; // copy element
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,10 +41,10 @@ Foam::List<T>::List(Istream& is)
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, List<T>& lst)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
{
|
||||
// Anull list
|
||||
lst.setSize(0);
|
||||
list.resize(0);
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
@ -55,7 +55,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& lst)
|
||||
// Compound: simply transfer contents
|
||||
if (firstToken.isCompound())
|
||||
{
|
||||
lst.transfer
|
||||
list.transfer
|
||||
(
|
||||
dynamicCast<token::Compound<List<T>>>
|
||||
(
|
||||
@ -72,8 +72,8 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& lst)
|
||||
{
|
||||
const label len = firstToken.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
lst.setSize(len);
|
||||
// Resize to length read
|
||||
list.resize(len);
|
||||
|
||||
// Read list contents depending on data format
|
||||
|
||||
@ -88,11 +88,12 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& lst)
|
||||
{
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
is >> lst[i];
|
||||
is >> list[i];
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, List<T>&) : reading entry"
|
||||
"operator>>(Istream&, List<T>&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -111,7 +112,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& lst)
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
lst[i] = element; // Copy the value
|
||||
list[i] = element; // Copy the value
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,11 +124,12 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& lst)
|
||||
{
|
||||
// Non-empty, binary, contiguous
|
||||
|
||||
is.read(reinterpret_cast<char*>(lst.data()), len*sizeof(T));
|
||||
is.read(reinterpret_cast<char*>(list.data()), len*sizeof(T));
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, List<T>&) : reading the binary block"
|
||||
"operator>>(Istream&, List<T>&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
}
|
||||
|
||||
@ -151,7 +153,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& lst)
|
||||
SLList<T> sll(is); // Read as singly-linked list
|
||||
|
||||
// Reallocate and move assign list elements
|
||||
lst = std::move(sll);
|
||||
list = std::move(sll);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@ -490,6 +490,44 @@ public:
|
||||
Istream& os,
|
||||
UList<T>& L
|
||||
);
|
||||
|
||||
|
||||
// Special Methods
|
||||
|
||||
//- A bitSet::test() method for a list of bool
|
||||
//
|
||||
// \return The element value, or false for out-of-range access
|
||||
template<class TypeT = T>
|
||||
typename std::enable_if<std::is_same<TypeT, bool>::value, bool>::type
|
||||
inline test(const label i) const
|
||||
{
|
||||
return (i >= 0 && i < size() && v_[i]);
|
||||
}
|
||||
|
||||
//- A bitSet::get() method for a list of bool
|
||||
//
|
||||
// \return The element value, or false for out-of-range access
|
||||
template<class TypeT = T>
|
||||
typename std::enable_if<std::is_same<TypeT, bool>::value, bool>::type
|
||||
inline get(const label i) const
|
||||
{
|
||||
return (i >= 0 && i < size_ && v_[i]);
|
||||
}
|
||||
|
||||
//- A bitSet::unset() method for a list of bool
|
||||
//
|
||||
// \return True if value changed and was not out-of-range
|
||||
template<class TypeT = T>
|
||||
typename std::enable_if<std::is_same<TypeT, bool>::value, bool>::type
|
||||
inline unset(const label i)
|
||||
{
|
||||
if (i >= 0 && i < size_ && v_[i])
|
||||
{
|
||||
v_[i] = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -225,16 +225,6 @@ inline void Foam::UList<T>::shallowCopy(const UList<T>& list)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UList<T>::operator[](const label i)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
checkIndex(i);
|
||||
#endif
|
||||
return v_[i];
|
||||
}
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Template specialization for bool
|
||||
@ -252,6 +242,16 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UList<T>::operator[](const label i)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
checkIndex(i);
|
||||
#endif
|
||||
return v_[i];
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UList<T>::operator[](const label i) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user