ENH: add front(), back() methods to List containers
- traditionally used first(), last() methods, but front(), back() are well-known from std::vector etc which makes the access more familiar. - support push_back() method for containers that already had append(). This increases name familiar and can help when porting between different C++ code bases. - support pop_back() method for List containers. This is similar to std::vector
This commit is contained in:
parent
db88265163
commit
c7e6ae30bf
@ -101,6 +101,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
printInfo(idl1);
|
||||
|
||||
Info<< "list() = ";
|
||||
idl1.list().writeList(Info, 0) << endl;
|
||||
|
||||
for (const label val : { 10, 30, 40, 50, 90, 80, 120 } )
|
||||
{
|
||||
testFind(val, idl1);
|
||||
|
@ -334,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
listApp.append(new Scalar(1.3*i));
|
||||
}
|
||||
listApp.emplace_append(100);
|
||||
listApp.emplace_back(100);
|
||||
|
||||
|
||||
Info<< nl
|
||||
@ -580,8 +580,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
PtrList<plane> planes;
|
||||
planes.emplace_append(vector::one, vector::one);
|
||||
planes.emplace_append(vector(1,2,3), vector::one);
|
||||
planes.emplace_back(vector::one, vector::one);
|
||||
planes.emplace_back(vector(1,2,3), vector::one);
|
||||
|
||||
Info<< nl << "appended values" << nl;
|
||||
for (const plane& p : planes)
|
||||
@ -594,15 +594,15 @@ int main(int argc, char *argv[])
|
||||
PtrDynList<plane> dynPlanes;
|
||||
|
||||
{
|
||||
dynPlanes.emplace_append(vector::one, vector::one);
|
||||
dynPlanes.emplace_append(vector(1,2,3), vector::one);
|
||||
dynPlanes.emplace_back(vector::one, vector::one);
|
||||
dynPlanes.emplace_back(vector(1,2,3), vector::one);
|
||||
dynPlanes.append(nullptr);
|
||||
|
||||
dynPlanes.set(6, new plane(vector(2,2,1), vector::one));
|
||||
dynPlanes.set(10, new plane(vector(4,5,6), vector::one));
|
||||
|
||||
dynPlanes.emplace(12, vector(3,2,1), vector::one);
|
||||
dynPlanes.emplace_append(Zero, vector::one);
|
||||
dynPlanes.emplace_back(Zero, vector::one);
|
||||
}
|
||||
|
||||
Info<< nl << "PtrDynList: ";
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -437,7 +437,10 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Append a value at the end of the list
|
||||
inline PackedList<Width>& append(const unsigned int val);
|
||||
inline void push_back(const unsigned int val);
|
||||
|
||||
//- Reduce size by 1 or more elements. Can be called on an empty list.
|
||||
inline void pop_back(label n = 1);
|
||||
|
||||
//- Remove and return the last element
|
||||
inline unsigned int remove();
|
||||
@ -556,6 +559,14 @@ public:
|
||||
|
||||
//- Alias for resize()
|
||||
void setSize(const label n, unsigned int val = 0u) { resize(n, val); }
|
||||
|
||||
//- Append a value at the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
PackedList<Width>& append(const unsigned int val)
|
||||
{
|
||||
this->push_back(val);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -693,15 +693,27 @@ inline bool Foam::PackedList<Width>::unset(const label i)
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
inline Foam::PackedList<Width>&
|
||||
Foam::PackedList<Width>::append(const unsigned int val)
|
||||
inline void Foam::PackedList<Width>::push_back(const unsigned int val)
|
||||
{
|
||||
const label idx = size();
|
||||
reserve(idx + 1);
|
||||
++size_;
|
||||
|
||||
reference(this, idx).set(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
inline void Foam::PackedList<Width>::pop_back(label n)
|
||||
{
|
||||
if (n >= size())
|
||||
{
|
||||
clear();
|
||||
}
|
||||
else if (n > 0)
|
||||
{
|
||||
resize(size() - n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,7 +142,7 @@ Foam::Istream& Foam::PackedList<Width>::readList(Istream& is)
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(tok);
|
||||
list.append(list.readValue(is));
|
||||
list.push_back(list.readValue(is));
|
||||
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BiIndirectList_H
|
||||
#define BiIndirectList_H
|
||||
#ifndef Foam_BiIndirectList_H
|
||||
#define Foam_BiIndirectList_H
|
||||
|
||||
#include "List.H"
|
||||
|
||||
@ -57,8 +57,7 @@ class BiIndirectList
|
||||
UList<T>& posList_;
|
||||
UList<T>& negList_;
|
||||
|
||||
labelList addressing_;
|
||||
|
||||
labelList addr_;
|
||||
|
||||
public:
|
||||
|
||||
@ -83,50 +82,56 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- The number of elements in the list
|
||||
inline label size() const noexcept;
|
||||
//- The number of elements in the list
|
||||
label size() const noexcept { return addr_.size(); }
|
||||
|
||||
//- True if the list is empty (ie, size() is zero).
|
||||
inline bool empty() const noexcept;
|
||||
//- True if the list is empty (ie, size() is zero).
|
||||
bool empty() const noexcept { return addr_.empty(); }
|
||||
|
||||
inline const UList<T>& posList() const noexcept;
|
||||
inline const UList<T>& negList() const noexcept;
|
||||
//- The list of positive values (without addressing)
|
||||
const UList<T>& posList() const noexcept { return posList_; }
|
||||
|
||||
//- Return the list addressing
|
||||
inline const labelList& addressing() const noexcept;
|
||||
//- The list of negative values (without addressing)
|
||||
const UList<T>& negList() const noexcept { return negList_; }
|
||||
|
||||
//- Calculate index given whether index is into posList or negList
|
||||
inline static label posIndex(const label i);
|
||||
inline static label negIndex(const label i);
|
||||
//- The addressing used for the list
|
||||
const labelList& addressing() const noexcept { return addr_; }
|
||||
|
||||
//- Calculate index given whether index is into posList or negList
|
||||
static label posIndex(const label i) noexcept { return i; }
|
||||
static label negIndex(const label i) noexcept { return (-i-1); }
|
||||
|
||||
|
||||
// Edit
|
||||
// Edit
|
||||
|
||||
//- Copy reset addressing
|
||||
inline void resetAddressing(const labelUList& addr);
|
||||
//- Copy reset addressing
|
||||
inline void resetAddressing(const labelUList& addr);
|
||||
|
||||
//- Move reset addressing
|
||||
inline void resetAddressing(labelList&& addr);
|
||||
//- Move reset addressing
|
||||
inline void resetAddressing(labelList&& addr);
|
||||
|
||||
//- Return the addressed elements as a List
|
||||
inline List<T> list() const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
// Member Operators
|
||||
|
||||
//- Return the addressed elements as a List
|
||||
inline List<T> operator()() const;
|
||||
//- Return the addressed elements as a List
|
||||
List<T> operator()() const { return this->list(); }
|
||||
|
||||
//- Return non-const access to an element
|
||||
inline T& operator[](const label i);
|
||||
//- Return non-const access to an element
|
||||
inline T& operator[](const label i);
|
||||
|
||||
//- Return const access to an element
|
||||
inline const T& operator[](const label i) const;
|
||||
//- Return const access to an element
|
||||
inline const T& operator[](const label i) const;
|
||||
|
||||
//- Assignment to UList of addressed elements
|
||||
inline void operator=(const UList<T>& ae);
|
||||
//- Assignment to UList of addressed elements
|
||||
inline void operator=(const UList<T>& ae);
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T& val);
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T& val);
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,22 +26,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i)
|
||||
{
|
||||
return -i-1;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -54,7 +38,7 @@ inline Foam::BiIndirectList<T>::BiIndirectList
|
||||
:
|
||||
posList_(const_cast<UList<T>&>(posList)),
|
||||
negList_(const_cast<UList<T>&>(negList)),
|
||||
addressing_(addr)
|
||||
addr_(addr)
|
||||
{}
|
||||
|
||||
|
||||
@ -68,72 +52,28 @@ inline Foam::BiIndirectList<T>::BiIndirectList
|
||||
:
|
||||
posList_(const_cast<UList<T>&>(posList)),
|
||||
negList_(const_cast<UList<T>&>(negList)),
|
||||
addressing_(std::move(addr))
|
||||
addr_(std::move(addr))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::BiIndirectList<T>::size() const noexcept
|
||||
inline void Foam::BiIndirectList<T>::resetAddressing(const labelUList& addr)
|
||||
{
|
||||
return addressing_.size();
|
||||
addr_ = addr;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::BiIndirectList<T>::empty() const noexcept
|
||||
inline void Foam::BiIndirectList<T>::resetAddressing(labelList&& addr)
|
||||
{
|
||||
return addressing_.empty();
|
||||
addr_.transfer(addr);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const Foam::UList<T>& Foam::BiIndirectList<T>::posList() const noexcept
|
||||
{
|
||||
return posList_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const Foam::UList<T>& Foam::BiIndirectList<T>::negList() const noexcept
|
||||
{
|
||||
return negList_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const Foam::labelList&
|
||||
Foam::BiIndirectList<T>::addressing() const noexcept
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::BiIndirectList<T>::resetAddressing
|
||||
(
|
||||
const labelUList& addr
|
||||
)
|
||||
{
|
||||
addressing_ = addr;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::BiIndirectList<T>::resetAddressing
|
||||
(
|
||||
labelList&& addr
|
||||
)
|
||||
{
|
||||
addressing_.transfer(addr);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::List<T> Foam::BiIndirectList<T>::operator()() const
|
||||
inline Foam::List<T> Foam::BiIndirectList<T>::list() const
|
||||
{
|
||||
List<T> result(size());
|
||||
|
||||
@ -146,51 +86,39 @@ inline Foam::List<T> Foam::BiIndirectList<T>::operator()() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::BiIndirectList<T>::operator[](const label i)
|
||||
{
|
||||
const label index = addressing_[i];
|
||||
const label index = addr_[i];
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
return posList_[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return negList_[-index-1];
|
||||
}
|
||||
return (index >= 0 ? posList_[index] : negList_[-index-1]);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::BiIndirectList<T>::operator[](const label i) const
|
||||
{
|
||||
const label index = addressing_[i];
|
||||
const label index = addr_[i];
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
return posList_[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return negList_[-index-1];
|
||||
}
|
||||
return (index >= 0 ? posList_[index] : negList_[-index-1]);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::BiIndirectList<T>::operator=(const UList<T>& ae)
|
||||
{
|
||||
if (addressing_.size() != ae.size())
|
||||
if (addr_.size() != ae.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Addressing and list of addressed elements "
|
||||
"have different sizes: "
|
||||
<< addressing_.size() << " " << ae.size()
|
||||
<< addr_.size() << " " << ae.size()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
forAll(addressing_, i)
|
||||
forAll(addr_, i)
|
||||
{
|
||||
operator[](i) = ae[i];
|
||||
}
|
||||
@ -200,7 +128,7 @@ inline void Foam::BiIndirectList<T>::operator=(const UList<T>& ae)
|
||||
template<class T>
|
||||
inline void Foam::BiIndirectList<T>::operator=(const T& val)
|
||||
{
|
||||
forAll(addressing_, i)
|
||||
forAll(addr_, i)
|
||||
{
|
||||
operator[](i) = val;
|
||||
}
|
||||
|
@ -123,49 +123,35 @@ public:
|
||||
// Access
|
||||
|
||||
//- The number of elements in the list
|
||||
inline label size() const noexcept
|
||||
{
|
||||
return addr_.size();
|
||||
}
|
||||
label size() const noexcept { return addr_.size(); }
|
||||
|
||||
//- True if the list is empty (ie, size() is zero).
|
||||
inline bool empty() const noexcept
|
||||
{
|
||||
return addr_.empty();
|
||||
}
|
||||
bool empty() const noexcept { return addr_.empty(); }
|
||||
|
||||
//- The list of values (without addressing)
|
||||
inline const UList<T>& values() const noexcept
|
||||
{
|
||||
return values_;
|
||||
}
|
||||
const UList<T>& values() const noexcept { return values_; }
|
||||
|
||||
//- The list of values (without addressing)
|
||||
inline UList<T>& values() noexcept
|
||||
{
|
||||
return values_;
|
||||
}
|
||||
UList<T>& values() noexcept { return values_; }
|
||||
|
||||
//- The addressing used for the list
|
||||
inline const Addr& addressing() const noexcept
|
||||
{
|
||||
return addr_;
|
||||
}
|
||||
const Addr& addressing() const noexcept { return addr_; }
|
||||
|
||||
|
||||
//- True if all entries have identical values, and list is non-empty
|
||||
inline bool uniform() const;
|
||||
|
||||
//- The first element of the list.
|
||||
inline const T& first() const;
|
||||
inline const T& front() const;
|
||||
|
||||
//- The first element of the list.
|
||||
inline T& first();
|
||||
inline T& front();
|
||||
|
||||
//- The last element of the list.
|
||||
inline const T& last() const;
|
||||
inline const T& back() const;
|
||||
|
||||
//- The last element of the list.
|
||||
inline T& last();
|
||||
inline T& back();
|
||||
|
||||
//- The forward circular index. The next index in the list
|
||||
//- which returns to the first at the end of the list
|
||||
@ -187,6 +173,9 @@ public:
|
||||
//- Return reverse circular value (ie, previous value in the list)
|
||||
inline T& rcValue(const label i);
|
||||
|
||||
//- Return the addressed elements as a List
|
||||
inline List<T> list() const;
|
||||
|
||||
|
||||
// Search
|
||||
|
||||
@ -211,7 +200,7 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Return the addressed elements as a List
|
||||
inline List<T> operator()() const;
|
||||
List<T> operator()() const { return this->list(); }
|
||||
|
||||
//- Non-const access to an element in the list
|
||||
inline T& operator[](const label i);
|
||||
@ -374,6 +363,25 @@ public:
|
||||
//- Write List, with line-breaks in ASCII when length exceeds shortLen.
|
||||
// Using '0' suppresses line-breaks entirely.
|
||||
Ostream& writeList(Ostream& os, const label shortLen=0) const;
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Access first element of the list, position [0]
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "front()")
|
||||
T& first() { return front(); }
|
||||
|
||||
//- Access first element of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "front()")
|
||||
const T& first() const { return front(); };
|
||||
|
||||
//- Access last element of the list, position [size()-1]
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "back()")
|
||||
T& last() { return back(); }
|
||||
|
||||
//- Access last element of the list, position [size()-1]
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "back()")
|
||||
const T& last() const { return back(); };
|
||||
};
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -124,28 +124,28 @@ inline Foam::label Foam::IndirectListBase<T, Addr>::rcIndex(const label i) const
|
||||
|
||||
|
||||
template<class T, class Addr>
|
||||
inline const T& Foam::IndirectListBase<T, Addr>::first() const
|
||||
inline const T& Foam::IndirectListBase<T, Addr>::front() const
|
||||
{
|
||||
return values_[addr_.first()];
|
||||
return values_[addr_.front()];
|
||||
}
|
||||
|
||||
template<class T, class Addr>
|
||||
inline T& Foam::IndirectListBase<T, Addr>::first()
|
||||
inline T& Foam::IndirectListBase<T, Addr>::front()
|
||||
{
|
||||
return values_[addr_.first()];
|
||||
return values_[addr_.front()];
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Addr>
|
||||
inline const T& Foam::IndirectListBase<T, Addr>::last() const
|
||||
inline const T& Foam::IndirectListBase<T, Addr>::back() const
|
||||
{
|
||||
return values_[addr_.last()];
|
||||
return values_[addr_.back()];
|
||||
}
|
||||
|
||||
template<class T, class Addr>
|
||||
inline T& Foam::IndirectListBase<T, Addr>::last()
|
||||
inline T& Foam::IndirectListBase<T, Addr>::back()
|
||||
{
|
||||
return values_[addr_.last()];
|
||||
return values_[addr_.back()];
|
||||
}
|
||||
|
||||
|
||||
@ -176,12 +176,8 @@ inline T& Foam::IndirectListBase<T, Addr>::rcValue(const label i)
|
||||
return values_[this->rcIndex(i)];
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Addr>
|
||||
inline Foam::List<T>
|
||||
Foam::IndirectListBase<T, Addr>::operator()() const
|
||||
inline Foam::List<T> Foam::IndirectListBase<T, Addr>::list() const
|
||||
{
|
||||
const label len = addr_.size();
|
||||
|
||||
@ -197,6 +193,8 @@ Foam::IndirectListBase<T, Addr>::operator()() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Addr>
|
||||
inline T& Foam::IndirectListBase<T, Addr>::operator[](const label i)
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ public:
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
// Use this or reserve() in combination with append().
|
||||
// Use this or reserve() in combination with push_back().
|
||||
inline void setCapacity(const label len);
|
||||
|
||||
//- Alter the size of the underlying storage,
|
||||
@ -245,47 +245,53 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Swap content, independent of sizing parameter
|
||||
template<int AnySizeMin>
|
||||
inline void swap(DynamicList<T, AnySizeMin>& other);
|
||||
//- Swap content, independent of sizing parameter
|
||||
template<int AnySizeMin>
|
||||
inline void swap(DynamicList<T, AnySizeMin>& other);
|
||||
|
||||
//- Transfer contents of the argument List into this.
|
||||
inline void transfer(List<T>& list);
|
||||
//- Transfer contents of the argument List into this.
|
||||
inline void transfer(List<T>& list);
|
||||
|
||||
//- Transfer contents of any sized DynamicList into this.
|
||||
template<int AnySizeMin>
|
||||
inline void transfer(DynamicList<T, AnySizeMin>& list);
|
||||
//- Transfer contents of any sized DynamicList into this.
|
||||
template<int AnySizeMin>
|
||||
inline void transfer(DynamicList<T, AnySizeMin>& list);
|
||||
|
||||
//- Copy append an element to the end of this list.
|
||||
inline void append(const T& val);
|
||||
//- Copy append an element to the end of this list.
|
||||
inline void push_back(const T& val);
|
||||
|
||||
//- Move append an element
|
||||
inline void append(T&& val);
|
||||
//- Move append an element
|
||||
inline void push_back(T&& val);
|
||||
|
||||
//- Append another list to the end of this list.
|
||||
inline void append(const UList<T>& lst);
|
||||
//- Copy append another list to the end of this list.
|
||||
inline void push_back(const UList<T>& list);
|
||||
|
||||
//- Append a FixedList to the end of this list.
|
||||
template<unsigned N>
|
||||
inline void append(const FixedList<T, N>& lst);
|
||||
//- Copy append a FixedList to the end of this list.
|
||||
template<unsigned N>
|
||||
inline void push_back(const FixedList<T, N>& list);
|
||||
|
||||
//- Append an initializer list at the end of this list.
|
||||
inline void append(std::initializer_list<T> lst);
|
||||
//- Copy append an initializer list at the end of this list.
|
||||
inline void push_back(std::initializer_list<T> list);
|
||||
|
||||
//- Append a IndirectList at the end of this list
|
||||
template<class Addr>
|
||||
inline void append(const IndirectListBase<T, Addr>& lst);
|
||||
//- Copy append an IndirectList at the end of this list
|
||||
template<class Addr>
|
||||
inline void push_back(const IndirectListBase<T, Addr>& lst);
|
||||
|
||||
//- Move append list
|
||||
inline void append(List<T>&& lst);
|
||||
//- Move append list
|
||||
inline void push_back(List<T>&& list);
|
||||
|
||||
//- Move append list
|
||||
template<int AnySizeMin>
|
||||
inline void append(DynamicList<T, AnySizeMin>&& list);
|
||||
//- Move append list
|
||||
template<int AnySizeMin>
|
||||
inline void push_back(DynamicList<T, AnySizeMin>&& list);
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
// \return the change in list length
|
||||
inline label appendUniq(const T& val);
|
||||
//- Append an element if not already in the list.
|
||||
// \return the change in list length
|
||||
inline label push_uniq(const T& val);
|
||||
|
||||
//- Reduce size by 1 or more elements. Can be called on an empty list.
|
||||
inline void pop_back(label n = 1);
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Remove and return the last element. Fatal on an empty list.
|
||||
inline T remove();
|
||||
@ -381,6 +387,51 @@ public:
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& list
|
||||
);
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Copy append an element to the end of this list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const T& val) { this->push_back(val); }
|
||||
|
||||
//- Move append an element
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(T&& val) { this->push_back(std::move(val)); }
|
||||
|
||||
//- Append another list to the end of this list.
|
||||
void append(const UList<T>& list) { this->push_back(list); }
|
||||
|
||||
//- Append a FixedList to the end of this list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
template<unsigned N>
|
||||
void append(const FixedList<T, N>& list) { this->push_back(list); }
|
||||
|
||||
//- Append an initializer list at the end of this list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(std::initializer_list<T> list) { this->push_back(list); }
|
||||
|
||||
//- Append a IndirectList at the end of this list
|
||||
template<class Addr>
|
||||
void append(const IndirectListBase<T, Addr>& list)
|
||||
{
|
||||
this->push_back(list);
|
||||
}
|
||||
|
||||
//- Move append list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(List<T>&& list) { this->push_back(std::move(list)); }
|
||||
|
||||
//- Move append list
|
||||
template<int AnySizeMin>
|
||||
void append(DynamicList<T, AnySizeMin>&& list)
|
||||
{
|
||||
this->push_back(std::move(list));
|
||||
}
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_uniq()")
|
||||
label appendUniq(const T& val) { return this->push_uniq(val); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -499,7 +499,7 @@ Foam::DynamicList<T, SizeMin>::transfer
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
const T& val
|
||||
)
|
||||
@ -512,7 +512,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
T&& val
|
||||
)
|
||||
@ -525,7 +525,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
const UList<T>& lst
|
||||
)
|
||||
@ -533,7 +533,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
if (this == &lst)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted appending to self"
|
||||
<< "Attempted push_back to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -549,7 +549,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<unsigned N>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
const FixedList<T, N>& lst
|
||||
)
|
||||
@ -565,7 +565,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
std::initializer_list<T> lst
|
||||
)
|
||||
@ -582,7 +582,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<class Addr>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
const IndirectListBase<T, Addr>& lst
|
||||
)
|
||||
@ -600,7 +600,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
List<T>&& list
|
||||
)
|
||||
@ -608,7 +608,7 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted appending to self"
|
||||
<< "Attempted push_back to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -626,18 +626,18 @@ inline void Foam::DynamicList<T, SizeMin>::append
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<int AnySizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::append
|
||||
inline void Foam::DynamicList<T, SizeMin>::push_back
|
||||
(
|
||||
DynamicList<T, AnySizeMin>&& list
|
||||
)
|
||||
{
|
||||
append(std::move(static_cast<List<T>&>(list)));
|
||||
push_back(std::move(static_cast<List<T>&>(list)));
|
||||
list.clearStorage(); // Ensure capacity=0
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::label Foam::DynamicList<T, SizeMin>::appendUniq(const T& val)
|
||||
inline Foam::label Foam::DynamicList<T, SizeMin>::push_uniq(const T& val)
|
||||
{
|
||||
if (this->found(val))
|
||||
{
|
||||
@ -645,12 +645,26 @@ inline Foam::label Foam::DynamicList<T, SizeMin>::appendUniq(const T& val)
|
||||
}
|
||||
else
|
||||
{
|
||||
this->append(val);
|
||||
this->push_back(val);
|
||||
return 1; // Increased list length by one
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::pop_back(label n)
|
||||
{
|
||||
if (n >= this->size())
|
||||
{
|
||||
clear();
|
||||
}
|
||||
else if (n > 0)
|
||||
{
|
||||
resize(this->size() - n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline T Foam::DynamicList<T, SizeMin>::remove()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -216,18 +216,17 @@ public:
|
||||
// \note Only meaningful for contiguous data
|
||||
inline char* data_bytes() noexcept;
|
||||
|
||||
//- Access first element of the list, position [0]
|
||||
inline T& front() noexcept;
|
||||
|
||||
//- The first element of the list, position [0]
|
||||
inline T& first() noexcept;
|
||||
//- Access first element of the list, position [0]
|
||||
inline const T& front() const noexcept;
|
||||
|
||||
//- The first element of the list, position [0]
|
||||
inline const T& first() const noexcept;
|
||||
//- Access last element of the list, position [N-1]
|
||||
inline T& back() noexcept;
|
||||
|
||||
//- The last element of the list, position [N-1]
|
||||
inline T& last() noexcept;
|
||||
|
||||
//- The last element of the list, position [N-1]
|
||||
inline const T& last() const noexcept;
|
||||
//- Access last element of the list, position [N-1]
|
||||
inline const T& back() const noexcept;
|
||||
|
||||
//- Number of contiguous bytes for the list data,
|
||||
// \note Only meaningful for contiguous data
|
||||
@ -501,6 +500,21 @@ public:
|
||||
{
|
||||
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash() {}
|
||||
};
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Access first element of the list, position [0] - front()
|
||||
T& first() noexcept { return front(); }
|
||||
|
||||
//- Access first element of the list, position [0] - front()
|
||||
const T& first() const noexcept { return front(); }
|
||||
|
||||
//- Access last element of the list, position [N-1] - back()
|
||||
T& last() noexcept { return back(); }
|
||||
|
||||
//- Access last element of the list, position [N-1] - back()
|
||||
const T& last() const noexcept { return back(); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -204,28 +204,28 @@ inline std::streamsize Foam::FixedList<T, N>::size_bytes() noexcept
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline T& Foam::FixedList<T, N>::first() noexcept
|
||||
inline T& Foam::FixedList<T, N>::front() noexcept
|
||||
{
|
||||
return v_[0];
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline const T& Foam::FixedList<T, N>::first() const noexcept
|
||||
inline const T& Foam::FixedList<T, N>::front() const noexcept
|
||||
{
|
||||
return v_[0];
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline T& Foam::FixedList<T, N>::last() noexcept
|
||||
inline T& Foam::FixedList<T, N>::back() noexcept
|
||||
{
|
||||
return v_[N-1];
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline const T& Foam::FixedList<T, N>::last() const noexcept
|
||||
inline const T& Foam::FixedList<T, N>::back() const noexcept
|
||||
{
|
||||
return v_[N-1];
|
||||
}
|
||||
|
@ -222,41 +222,47 @@ public:
|
||||
void setSize(const label n, const T& val) { this->resize(n, val); }
|
||||
|
||||
|
||||
// Edit
|
||||
// Edit
|
||||
|
||||
//- Append an element at the end of the list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
inline void append(const T& val);
|
||||
//- Transfer the contents of the argument List into this list
|
||||
//- and annul the argument list
|
||||
void transfer(List<T>& list);
|
||||
|
||||
//- Move append an element at the end of the list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
inline void append(T&& val);
|
||||
//- Transfer the contents of the argument List into this list
|
||||
//- and annul the argument list
|
||||
template<int SizeMin>
|
||||
void transfer(DynamicList<T, SizeMin>& list);
|
||||
|
||||
//- Append a List to the end of this list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
inline void append(const UList<T>& list);
|
||||
//- Return subscript-checked element of UList and resizing the list
|
||||
//- if required.
|
||||
inline T& newElmt(const label i);
|
||||
|
||||
//- Append IndirectList contents at the end of this list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
template<class Addr>
|
||||
inline void append(const IndirectListBase<T, Addr>& list);
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
// \return the change in list length
|
||||
inline label appendUniq(const T& val);
|
||||
// Edit
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
//- and annul the argument list
|
||||
void transfer(List<T>& list);
|
||||
//- Append an element at the end of the list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
inline void push_back(const T& val);
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
//- and annul the argument list
|
||||
template<int SizeMin>
|
||||
void transfer(DynamicList<T, SizeMin>& list);
|
||||
//- Move append an element at the end of the list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
inline void push_back(T&& val);
|
||||
|
||||
//- Return subscript-checked element of UList and resizing the list
|
||||
//- if required.
|
||||
inline T& newElmt(const label i);
|
||||
//- Append a List to the end of this list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
inline void push_back(const UList<T>& list);
|
||||
|
||||
//- Append IndirectList contents at the end of this list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
template<class Addr>
|
||||
inline void push_back(const IndirectListBase<T, Addr>& list);
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
// \return the change in list length
|
||||
inline label push_uniq(const T& val);
|
||||
|
||||
//- Reduce size by 1 or more elements. Can be called on an empty list.
|
||||
inline void pop_back(label n = 1);
|
||||
|
||||
|
||||
// Member Operators
|
||||
@ -346,6 +352,37 @@ public:
|
||||
(*this)[i] = val;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Append an element at the end of the list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const T& val) { this->push_back(val); }
|
||||
|
||||
//- Move append an element at the end of the list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(T&& val) { this->push_back(std::move(val)); }
|
||||
|
||||
//- Append a List to the end of this list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const UList<T>& list) { this->push_back(list); }
|
||||
|
||||
//- Append IndirectList contents at the end of this list
|
||||
// If this is frequently required, consider a DynamicList
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
template<class Addr>
|
||||
void append(const IndirectListBase<T, Addr>& list)
|
||||
{
|
||||
this->push_back(list);
|
||||
}
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_uniq()")
|
||||
label appendUniq(const T& val) { return this->push_uniq(val); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -172,7 +172,7 @@ inline T& Foam::List<T>::newElmt(const label i)
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::append(const T& val)
|
||||
inline void Foam::List<T>::push_back(const T& val)
|
||||
{
|
||||
const label idx = this->size();
|
||||
resize(idx + 1);
|
||||
@ -182,7 +182,7 @@ inline void Foam::List<T>::append(const T& val)
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::append(T&& val)
|
||||
inline void Foam::List<T>::push_back(T&& val)
|
||||
{
|
||||
const label idx = this->size();
|
||||
resize(idx + 1);
|
||||
@ -192,12 +192,12 @@ inline void Foam::List<T>::append(T&& val)
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::append(const UList<T>& list)
|
||||
inline void Foam::List<T>::push_back(const UList<T>& list)
|
||||
{
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted appending to self" << abort(FatalError);
|
||||
<< "Attempted push_back to self" << abort(FatalError);
|
||||
}
|
||||
|
||||
label idx = this->size();
|
||||
@ -214,7 +214,7 @@ inline void Foam::List<T>::append(const UList<T>& list)
|
||||
|
||||
template<class T>
|
||||
template<class Addr>
|
||||
inline void Foam::List<T>::append(const IndirectListBase<T, Addr>& list)
|
||||
inline void Foam::List<T>::push_back(const IndirectListBase<T, Addr>& list)
|
||||
{
|
||||
label idx = this->size();
|
||||
const label n = list.size();
|
||||
@ -229,7 +229,7 @@ inline void Foam::List<T>::append(const IndirectListBase<T, Addr>& list)
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::List<T>::appendUniq(const T& val)
|
||||
inline Foam::label Foam::List<T>::push_uniq(const T& val)
|
||||
{
|
||||
if (this->found(val))
|
||||
{
|
||||
@ -237,12 +237,26 @@ inline Foam::label Foam::List<T>::appendUniq(const T& val)
|
||||
}
|
||||
else
|
||||
{
|
||||
this->append(val);
|
||||
this->push_back(val);
|
||||
return 1; // Increased list length by one
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::pop_back(label n)
|
||||
{
|
||||
if (n >= this->size())
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
else if (n > 0)
|
||||
{
|
||||
resize(this->size() - n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
|
@ -272,17 +272,17 @@ public:
|
||||
// \note Only meaningful for contiguous data
|
||||
inline char* data_bytes() noexcept;
|
||||
|
||||
//- Return the first element of the list
|
||||
inline T& first();
|
||||
//- Access first element of the list, position [0]
|
||||
inline T& front();
|
||||
|
||||
//- Return first element of the list
|
||||
inline const T& first() const;
|
||||
//- Access first element of the list
|
||||
inline const T& front() const;
|
||||
|
||||
//- Return the last element of the list
|
||||
inline T& last();
|
||||
//- Access last element of the list, position [size()-1]
|
||||
inline T& back();
|
||||
|
||||
//- Return the last element of the list
|
||||
inline const T& last() const;
|
||||
//- Access last element of the list, position [size()-1]
|
||||
inline const T& back() const;
|
||||
|
||||
//- Number of contiguous bytes for the List data.
|
||||
// \note Only meaningful for contiguous data
|
||||
@ -580,6 +580,25 @@ public:
|
||||
{
|
||||
FOAM_DEPRECATED_FOR(2021-04, "hasher()") Hash() {}
|
||||
};
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Access first element of the list, position [0]
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "front()")
|
||||
T& first() { return front(); }
|
||||
|
||||
//- Access first element of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "front()")
|
||||
const T& first() const { return front(); };
|
||||
|
||||
//- Access last element of the list, position [size()-1]
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "back()")
|
||||
T& last() { return back(); }
|
||||
|
||||
//- Access last element of the list, position [size()-1]
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "back()")
|
||||
const T& last() const { return back(); };
|
||||
};
|
||||
|
||||
|
||||
|
@ -199,28 +199,28 @@ inline bool Foam::UList<T>::uniform() const
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UList<T>::first()
|
||||
inline T& Foam::UList<T>::front()
|
||||
{
|
||||
return this->operator[](0);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UList<T>::first() const
|
||||
inline const T& Foam::UList<T>::front() const
|
||||
{
|
||||
return this->operator[](0);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UList<T>::last()
|
||||
inline T& Foam::UList<T>::back()
|
||||
{
|
||||
return this->operator[](this->size()-1);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UList<T>::last() const
|
||||
inline const T& Foam::UList<T>::back() const
|
||||
{
|
||||
return this->operator[](this->size()-1);
|
||||
}
|
||||
|
@ -1097,7 +1097,7 @@ void Foam::ListOps::uniqueEqOp<T>::operator()
|
||||
{
|
||||
if (!x.found(val))
|
||||
{
|
||||
x.append(val);
|
||||
x.push_back(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,33 +143,36 @@ public:
|
||||
template<int AnySizeMin>
|
||||
inline void swap(PtrDynList<T, AnySizeMin>& other);
|
||||
|
||||
//- Construct and append an element to the end of the list
|
||||
//- Construct an element at the end of the list
|
||||
template<class... Args>
|
||||
inline void emplace_append(Args&&... args);
|
||||
inline void emplace_back(Args&&... args);
|
||||
|
||||
//- Append an element to the end of the list
|
||||
inline void append(T* ptr);
|
||||
inline void push_back(T* ptr);
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
inline void append(std::unique_ptr<T>&& ptr);
|
||||
inline void push_back(std::unique_ptr<T>&& ptr);
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
inline void append(autoPtr<T>&& ptr);
|
||||
inline void push_back(autoPtr<T>&& ptr);
|
||||
|
||||
//- Move or clone append a tmp to the end of the list
|
||||
inline void append(const refPtr<T>& ptr);
|
||||
inline void push_back(const refPtr<T>& ptr);
|
||||
|
||||
//- Move or clone append a tmp to the end of the list
|
||||
inline void append(const tmp<T>& ptr);
|
||||
inline void push_back(const tmp<T>& ptr);
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
inline void append(PtrList<T>&& other);
|
||||
inline void push_back(PtrList<T>&& other);
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
template<int AnySizeMin>
|
||||
inline void append(PtrDynList<T, AnySizeMin>&& other);
|
||||
inline void push_back(PtrDynList<T, AnySizeMin>&& other);
|
||||
|
||||
//- Remove and return the top element
|
||||
//- Reduce size by 1 or more elements. Can be called on an empty list.
|
||||
inline void pop_back(label n = 1);
|
||||
|
||||
//- Remove and return the top element. Can be called on an empty list.
|
||||
inline autoPtr<T> remove();
|
||||
|
||||
//- Construct and set an element
|
||||
@ -225,17 +228,48 @@ public:
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
void append(autoPtr<T>& ptr)
|
||||
{
|
||||
this->append(std::move(ptr));
|
||||
}
|
||||
|
||||
//- Set element to given autoPtr and return old element
|
||||
autoPtr<T> set(const label i, autoPtr<T>& ptr)
|
||||
{
|
||||
return this->set(i, std::move(ptr));
|
||||
}
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
void append(autoPtr<T>& ptr) { this->push_back(std::move(ptr)); }
|
||||
|
||||
//- Append an element to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(T* ptr) { this->push_back(ptr); }
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(std::unique_ptr<T>&& ptr)
|
||||
{
|
||||
this->push_back(std::move(ptr));
|
||||
}
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(autoPtr<T>&& ptr) { this->push_back(std::move(ptr)); }
|
||||
|
||||
//- Move or clone append a tmp to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const refPtr<T>& ptr) { this->push_back(ptr); }
|
||||
|
||||
//- Move or clone append a tmp to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const tmp<T>& ptr) { this->push_back(ptr); }
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(PtrList<T>&& other) { this->push_back(std::move(other)); }
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
template<int AnySizeMin>
|
||||
void append(PtrDynList<T, AnySizeMin>&& other)
|
||||
{
|
||||
this->push_back(other);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -225,14 +225,14 @@ inline void Foam::PtrDynList<T, SizeMin>::swap
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<class... Args>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::emplace_append(Args&&... args)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::emplace_back(Args&&... args)
|
||||
{
|
||||
this->append(new T(std::forward<Args>(args)...));
|
||||
this->push_back(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::append(T* ptr)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::push_back(T* ptr)
|
||||
{
|
||||
const label idx = this->size();
|
||||
resize(idx + 1);
|
||||
@ -241,35 +241,35 @@ inline void Foam::PtrDynList<T, SizeMin>::append(T* ptr)
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::append(std::unique_ptr<T>&& ptr)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::push_back(std::unique_ptr<T>&& ptr)
|
||||
{
|
||||
this->append(ptr.release());
|
||||
this->push_back(ptr.release());
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::append(autoPtr<T>&& ptr)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::push_back(autoPtr<T>&& ptr)
|
||||
{
|
||||
this->append(ptr.release());
|
||||
this->push_back(ptr.release());
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::append(const refPtr<T>& ptr)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::push_back(const refPtr<T>& ptr)
|
||||
{
|
||||
this->append(ptr.ptr()); // release or clone
|
||||
this->push_back(ptr.ptr()); // release or clone
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::append(const tmp<T>& ptr)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::push_back(const tmp<T>& ptr)
|
||||
{
|
||||
this->append(ptr.ptr()); // release or clone
|
||||
this->push_back(ptr.ptr()); // release or clone
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::append(PtrList<T>&& other)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::push_back(PtrList<T>&& other)
|
||||
{
|
||||
const label idx = this->size();
|
||||
const label len = other.size();
|
||||
@ -287,7 +287,7 @@ inline void Foam::PtrDynList<T, SizeMin>::append(PtrList<T>&& other)
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<int AnySizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::append
|
||||
inline void Foam::PtrDynList<T, SizeMin>::push_back
|
||||
(
|
||||
PtrDynList<T, AnySizeMin>&& other
|
||||
)
|
||||
@ -299,7 +299,7 @@ inline void Foam::PtrDynList<T, SizeMin>::append
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted append to self"
|
||||
<< "Attempted push_back to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -317,6 +317,20 @@ inline void Foam::PtrDynList<T, SizeMin>::append
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::pop_back(label n)
|
||||
{
|
||||
if (n >= this->size())
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
else if (n > 0)
|
||||
{
|
||||
this->resize(this->size() - n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::autoPtr<T> Foam::PtrDynList<T, SizeMin>::remove()
|
||||
{
|
||||
|
@ -153,25 +153,25 @@ public:
|
||||
|
||||
//- Construct and append an element to the end of the list
|
||||
template<class... Args>
|
||||
inline void emplace_append(Args&&... args);
|
||||
inline void emplace_back(Args&&... args);
|
||||
|
||||
//- Append an element to the end of the list
|
||||
inline void append(T* ptr);
|
||||
inline void push_back(T* ptr);
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
inline void append(std::unique_ptr<T>&& ptr);
|
||||
inline void push_back(std::unique_ptr<T>&& ptr);
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
inline void append(autoPtr<T>&& ptr);
|
||||
inline void push_back(autoPtr<T>&& ptr);
|
||||
|
||||
//- Move or clone append a refPtr to the end of the list
|
||||
inline void append(const refPtr<T>& ptr);
|
||||
inline void push_back(const refPtr<T>& ptr);
|
||||
|
||||
//- Move or clone append a tmp to the end of the list
|
||||
inline void append(const tmp<T>& ptr);
|
||||
inline void push_back(const tmp<T>& ptr);
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
inline void append(PtrList<T>&& other);
|
||||
inline void push_back(PtrList<T>&& other);
|
||||
|
||||
//- Construct and set an element
|
||||
template<class... Args>
|
||||
@ -220,17 +220,41 @@ public:
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
void append(autoPtr<T>& ptr)
|
||||
{
|
||||
this->append(std::move(ptr));
|
||||
}
|
||||
|
||||
//- Set element to given autoPtr and return old element
|
||||
autoPtr<T> set(const label i, autoPtr<T>& ptr)
|
||||
{
|
||||
return this->set(i, std::move(ptr));
|
||||
}
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
void append(autoPtr<T>& ptr) { this->push_back(std::move(ptr)); }
|
||||
|
||||
//- Append an element to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(T* ptr) { this->push_back(ptr); }
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(std::unique_ptr<T>&& ptr)
|
||||
{
|
||||
this->push_back(std::move(ptr));
|
||||
}
|
||||
|
||||
//- Move append an element to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(autoPtr<T>&& ptr) { this->push_back(std::move(ptr)); }
|
||||
|
||||
//- Move or clone append a tmp to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const refPtr<T>& ptr) { this->push_back(ptr); }
|
||||
|
||||
//- Move or clone append a tmp to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const tmp<T>& ptr) { this->push_back(ptr); }
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(PtrList<T>&& other) { this->push_back(std::move(other)); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -103,54 +103,54 @@ inline void Foam::PtrList<T>::clear()
|
||||
|
||||
template<class T>
|
||||
template<class... Args>
|
||||
inline void Foam::PtrList<T>::emplace_append(Args&&... args)
|
||||
inline void Foam::PtrList<T>::emplace_back(Args&&... args)
|
||||
{
|
||||
UPtrList<T>::append(new T(std::forward<Args>(args)...));
|
||||
UPtrList<T>::push_back(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(T* ptr)
|
||||
inline void Foam::PtrList<T>::push_back(T* ptr)
|
||||
{
|
||||
UPtrList<T>::append(ptr);
|
||||
UPtrList<T>::push_back(ptr);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(std::unique_ptr<T>&& ptr)
|
||||
inline void Foam::PtrList<T>::push_back(std::unique_ptr<T>&& ptr)
|
||||
{
|
||||
UPtrList<T>::append(ptr.release());
|
||||
UPtrList<T>::push_back(ptr.release());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(autoPtr<T>&& ptr)
|
||||
inline void Foam::PtrList<T>::push_back(autoPtr<T>&& ptr)
|
||||
{
|
||||
UPtrList<T>::append(ptr.release());
|
||||
UPtrList<T>::push_back(ptr.release());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(const refPtr<T>& ptr)
|
||||
inline void Foam::PtrList<T>::push_back(const refPtr<T>& ptr)
|
||||
{
|
||||
UPtrList<T>::append(ptr.ptr()); // release or clone
|
||||
UPtrList<T>::push_back(ptr.ptr()); // release or clone
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(const tmp<T>& ptr)
|
||||
inline void Foam::PtrList<T>::push_back(const tmp<T>& ptr)
|
||||
{
|
||||
UPtrList<T>::append(ptr.ptr()); // release or clone
|
||||
UPtrList<T>::push_back(ptr.ptr()); // release or clone
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(PtrList<T>&& other)
|
||||
inline void Foam::PtrList<T>::push_back(PtrList<T>&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted append to self"
|
||||
<< "Attempted push_back to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
@ -217,17 +217,17 @@ public:
|
||||
//- True if the list is empty (ie, size() is zero)
|
||||
inline bool empty() const noexcept;
|
||||
|
||||
//- Return reference to the first element of the list
|
||||
inline T& first();
|
||||
//- Reference to the first element of the list
|
||||
inline T& front();
|
||||
|
||||
//- Return reference to first element of the list
|
||||
inline const T& first() const;
|
||||
//- Reference to first element of the list
|
||||
inline const T& front() const;
|
||||
|
||||
//- Return reference to the last element of the list
|
||||
inline T& last();
|
||||
//- Reference to the last element of the list
|
||||
inline T& back();
|
||||
|
||||
//- Return reference to the last element of the list
|
||||
inline const T& last() const;
|
||||
//- Reference to the last element of the list
|
||||
inline const T& back() const;
|
||||
|
||||
//- Return const pointer to element (can be nullptr),
|
||||
//- or nullptr for out-of-range access (ie, \em with bounds checking).
|
||||
@ -267,10 +267,10 @@ public:
|
||||
label squeezeNull();
|
||||
|
||||
//- Append an element to the end of the list
|
||||
inline void append(T* ptr);
|
||||
inline void push_back(T* ptr);
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
inline void append(UPtrList<T>&& other);
|
||||
inline void push_back(UPtrList<T>&& other);
|
||||
|
||||
//- Swap content
|
||||
inline void swap(UPtrList<T>& list);
|
||||
@ -474,6 +474,33 @@ public:
|
||||
Ostream& os,
|
||||
const UPtrList<T>& list
|
||||
);
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Reference to the first element of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "front()")
|
||||
T& first() { return front(); }
|
||||
|
||||
//- Return reference to first element of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "front()")
|
||||
const T& first() const { return front(); }
|
||||
|
||||
//- Return reference to the last element of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "back()")
|
||||
T& last() { return back(); }
|
||||
|
||||
//- Return reference to the last element of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "back()")
|
||||
const T& last() const{ return back(); }
|
||||
|
||||
//- Append an element to the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(T* ptr) { this->push_back(ptr); }
|
||||
|
||||
//- Move append another list to the end of this list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(UPtrList<T>&& other) { this->push_back(std::move(other)); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -179,28 +179,28 @@ inline void Foam::UPtrList<T>::transfer(UPtrList<T>& list)
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::first()
|
||||
inline T& Foam::UPtrList<T>::front()
|
||||
{
|
||||
return this->operator[](0);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UPtrList<T>::first() const
|
||||
inline const T& Foam::UPtrList<T>::front() const
|
||||
{
|
||||
return this->operator[](0);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::last()
|
||||
inline T& Foam::UPtrList<T>::back()
|
||||
{
|
||||
return this->operator[](this->size()-1);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UPtrList<T>::last() const
|
||||
inline const T& Foam::UPtrList<T>::back() const
|
||||
{
|
||||
return this->operator[](this->size()-1);
|
||||
}
|
||||
@ -214,16 +214,16 @@ inline void Foam::UPtrList<T>::resize(const label newLen)
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::append(T* ptr)
|
||||
inline void Foam::UPtrList<T>::push_back(T* ptr)
|
||||
{
|
||||
ptrs_.append(ptr);
|
||||
ptrs_.push_back(ptr);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::append(UPtrList<T>&& other)
|
||||
inline void Foam::UPtrList<T>::push_back(UPtrList<T>&& other)
|
||||
{
|
||||
ptrs_.append(other.ptrs_);
|
||||
ptrs_.push_back(other.ptrs_);
|
||||
other.ptrs_.clear();
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ public:
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
// Use this or reserve() in combination with append().
|
||||
// Use this or reserve() in combination with push_back().
|
||||
inline void setCapacity(const label len);
|
||||
|
||||
//- Alter the size of the underlying storage,
|
||||
@ -283,15 +283,18 @@ public:
|
||||
inline void transfer(DynamicField<T, AnySizeMin>& list);
|
||||
|
||||
//- Append an element at the end of the list
|
||||
inline void append(const T& val);
|
||||
inline void push_back(const T& val);
|
||||
|
||||
//- Move append an element
|
||||
inline void append(T&& val);
|
||||
inline void push_back(T&& val);
|
||||
|
||||
//- Append a List at the end of this list
|
||||
inline void append(const UList<T>& list);
|
||||
inline void push_back(const UList<T>& list);
|
||||
|
||||
//- Remove and return the top element
|
||||
//- Reduce size by 1 or more elements. Can be called on an empty list.
|
||||
inline void pop_back(label n = 1);
|
||||
|
||||
//- Remove and return the last element. Fatal on an empty list.
|
||||
inline T remove();
|
||||
|
||||
|
||||
@ -349,6 +352,21 @@ public:
|
||||
Ostream& os,
|
||||
const DynamicField<T, SizeMin>& rhs
|
||||
);
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Append an element at the end of the list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const T& val) { this->push_back(val); }
|
||||
|
||||
//- Move append an element
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(T&& val) { this->push_back(std::move(val)); }
|
||||
|
||||
//- Append a List at the end of this list
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_back()")
|
||||
void append(const UList<T>& list) { this->push_back(list); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -591,7 +591,7 @@ inline void Foam::DynamicField<T, SizeMin>::transfer
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::append
|
||||
inline void Foam::DynamicField<T, SizeMin>::push_back
|
||||
(
|
||||
const T& val
|
||||
)
|
||||
@ -604,7 +604,7 @@ inline void Foam::DynamicField<T, SizeMin>::append
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::append
|
||||
inline void Foam::DynamicField<T, SizeMin>::push_back
|
||||
(
|
||||
T&& val
|
||||
)
|
||||
@ -617,7 +617,7 @@ inline void Foam::DynamicField<T, SizeMin>::append
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::append
|
||||
inline void Foam::DynamicField<T, SizeMin>::push_back
|
||||
(
|
||||
const UList<T>& list
|
||||
)
|
||||
@ -625,7 +625,7 @@ inline void Foam::DynamicField<T, SizeMin>::append
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted appending to self"
|
||||
<< "Attempted push_back to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -639,6 +639,20 @@ inline void Foam::DynamicField<T, SizeMin>::append
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::pop_back(label n)
|
||||
{
|
||||
if (n >= this->size())
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
else if (n > 0)
|
||||
{
|
||||
resize(this->size() - n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline T Foam::DynamicField<T, SizeMin>::remove()
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -79,6 +79,15 @@ class hexCell
|
||||
|
||||
public:
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- The front() accessor (from FixedList) has no purpose
|
||||
void front() = delete;
|
||||
|
||||
//- The back() accessor (from FixedList) has no purpose
|
||||
void back() = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct, with invalid point labels (-1)
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -77,6 +77,15 @@ class tetCell
|
||||
|
||||
public:
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- The front() accessor (from FixedList) has no purpose
|
||||
void front() = delete;
|
||||
|
||||
//- The back() accessor (from FixedList) has no purpose
|
||||
void back() = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct, with invalid point labels (-1)
|
||||
|
@ -73,6 +73,15 @@ class triFace
|
||||
{
|
||||
public:
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- The front() accessor (from FixedList) has no purpose
|
||||
void front() = delete;
|
||||
|
||||
//- The back() accessor (from FixedList) has no purpose
|
||||
void back() = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct, with invalid point labels (-1)
|
||||
|
@ -91,6 +91,12 @@ public:
|
||||
//- Default construct
|
||||
tetPoints() = default;
|
||||
|
||||
//- The front() accessor (from FixedList) has no purpose
|
||||
void front() = delete;
|
||||
|
||||
//- The back() accessor (from FixedList) has no purpose
|
||||
void back() = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
|
@ -85,6 +85,12 @@ public:
|
||||
//- Default construct
|
||||
triPoints() = default;
|
||||
|
||||
//- The front() accessor (from FixedList) has no purpose
|
||||
void front() = delete;
|
||||
|
||||
//- The back() accessor (from FixedList) has no purpose
|
||||
void back() = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
|
@ -83,6 +83,12 @@ public:
|
||||
//- Move assignment
|
||||
boolVector& operator=(boolVector&&) = default;
|
||||
|
||||
//- The front() accessor (from FixedList) has no purpose
|
||||
void front() = delete;
|
||||
|
||||
//- The back() accessor (from FixedList) has no purpose
|
||||
void back() = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,7 +52,7 @@ Foam::Enum<EnumType>::Enum
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class EnumType>
|
||||
void Foam::Enum<EnumType>::append
|
||||
void Foam::Enum<EnumType>::push_back
|
||||
(
|
||||
std::initializer_list<std::pair<EnumType, const char*>> list
|
||||
)
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,8 +37,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Enum_H
|
||||
#define Enum_H
|
||||
#ifndef Foam_Enum_H
|
||||
#define Foam_Enum_H
|
||||
|
||||
#include "wordList.H"
|
||||
#include <ostream>
|
||||
@ -131,7 +131,7 @@ public:
|
||||
|
||||
//- Append value/key pairs to the lists of known enumerations
|
||||
// Does not check for duplicate entries
|
||||
void append
|
||||
void push_back
|
||||
(
|
||||
std::initializer_list<std::pair<EnumType, const char*>> list
|
||||
);
|
||||
@ -351,6 +351,16 @@ public:
|
||||
{
|
||||
return get(key, dict);
|
||||
}
|
||||
|
||||
//- Append value/key pairs to the lists of known enumerations
|
||||
// Does not check for duplicate entries
|
||||
void append
|
||||
(
|
||||
std::initializer_list<std::pair<EnumType, const char*>> list
|
||||
)
|
||||
{
|
||||
push_back(list);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -104,13 +104,9 @@ public:
|
||||
//- Clear the list, i.e. set size to zero.
|
||||
inline void clear();
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
FOAM_DEPRECATED_FOR(2022-05, "appendUniq method")
|
||||
inline void append(const word& val);
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
// \return the change in list length
|
||||
inline label appendUniq(const word& val);
|
||||
inline label push_uniq(const word& val);
|
||||
|
||||
//- Return the hash of words/indices for inspection
|
||||
inline const HashTable<label>& lookup() const;
|
||||
@ -185,6 +181,18 @@ public:
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
FOAM_DEPRECATED_FOR(2022-05, "push_uniq method")
|
||||
void append(const word& val) { this->push_uniq(val); }
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
FOAM_DEPRECATED_FOR(2022-10, "push_uniq method")
|
||||
void push_back(const word& val) { this->push_uniq(val); }
|
||||
|
||||
//- Append an element if not already in the list.
|
||||
//FOAM_DEPRECATED_FOR(2022-10, "push_uniq method")
|
||||
label appendUniq(const word& val) { return this->push_uniq(val); }
|
||||
|
||||
//- Deprecated(2019-01) Is the specified name found in the list?
|
||||
// \deprecated(2019-01) - use found() method
|
||||
FOAM_DEPRECATED_FOR(2019-01, "found() method")
|
||||
|
@ -97,20 +97,11 @@ inline void Foam::hashedWordList::clear()
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::hashedWordList::append(const word& val)
|
||||
inline Foam::label Foam::hashedWordList::push_uniq(const word& val)
|
||||
{
|
||||
if (lookup_.insert(val, size()))
|
||||
{
|
||||
wordList::append(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::hashedWordList::appendUniq(const word& val)
|
||||
{
|
||||
if (lookup_.insert(val, size()))
|
||||
{
|
||||
wordList::append(val);
|
||||
wordList::push_back(val);
|
||||
return 1; // Increased list length by one
|
||||
}
|
||||
|
||||
|
@ -70,11 +70,20 @@ class Pair
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
// Generated Methods
|
||||
|
||||
//- Default construct
|
||||
Pair() = default;
|
||||
|
||||
//- The front() accessor (from FixedList) has no purpose
|
||||
void front() = delete;
|
||||
|
||||
//- The back() accessor (from FixedList) has no purpose
|
||||
void back() = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Copy construct from components
|
||||
inline Pair(const T& f, const T& s);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user