45 #ifndef Foam_DynamicList_H 46 #define Foam_DynamicList_H 58 template<
class T,
int SizeMin>
61 template<
class T,
int SizeMin>
62 Ostream& operator<<(Ostream& os, const DynamicList<T, SizeMin>& list);
69 template<
class T,
int SizeMin = 16>
74 static_assert(SizeMin > 0,
"Invalid min size parameter");
91 template<
class ListType>
92 inline void doAssignDynList(
const ListType& list);
96 inline void doCapacity(
const bool nocopy,
const label len);
101 inline void doReserve(
const bool nocopy,
const label len);
106 inline void doResize(
const bool nocopy,
const label len);
110 bool readBracketList(
Istream& is);
121 inline explicit DynamicList(
const label initialCapacity);
124 inline explicit DynamicList(
const std::pair<label,label>& sizing);
136 template<
int AnySizeMin>
151 inline explicit DynamicList(std::initializer_list<T> lst);
161 template<
int AnySizeMin>
211 inline void reserve(
const label len);
230 inline void resize(
const label len);
233 inline void resize(
const label len,
const T& val);
266 template<
int AnySizeMin>
273 template<
int AnySizeMin>
278 template<class... Args>
305 template<
int AnySizeMin>
327 inline
T remove(const label idx, const
bool fast=false);
336 inline label
remove(
std::initializer_list<label> start_size);
344 inline label
subset(
std::initializer_list<label> start_size);
369 template<
int AnySizeMin>
386 template<
int AnySizeMin>
423 DynamicList<T, SizeMin>&
shrink()
451 void append(
const IndirectListBase<T, Addr>& list)
461 template<
int AnySizeMin>
462 void append(DynamicList<T, AnySizeMin>&& list)
476 template<
class T,
int SizeMin>
477 Istream&
operator>>(Istream& is, DynamicList<T, SizeMin>& list)
479 return list.readList(is);
484 template<
class T,
int SizeMin>
485 Ostream& operator<<(Ostream& os, const DynamicList<T, SizeMin>& list)
487 return (
os <<
static_cast<const UList<T>&
>(list));
494 template<
class T,
int SizeMin>
495 struct Hash<DynamicList<
T, SizeMin>> : List<T>::hasher {};
509 template<
class T,
int SizeMinA,
int SizeMinB>
510 inline void Swap(DynamicList<T, SizeMinA>& a, DynamicList<T, SizeMinB>&
b)
friend Ostream & operator(Ostream &os, const DynamicList< T, SizeMin > &list)
Write to Ostream.
A 1D vector of objects of type <T> with a fixed length <N>.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void reserve_nocopy(const label len)
Reserve allocation space for at least this size, allocating new space if required without retaining o...
constexpr DynamicList() noexcept
Default construct, an empty list without allocation.
A range or interval of labels defined by a start and a size.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void shrink_unsafe()
Shrink the internal bookkeeping of the allocated space to the number of addressed elements without af...
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
label appendUniq(const T &val)
Same as push_uniq()
void setCapacity(const label len)
Alter the size of the underlying storage.
void setSize(const label n)
Alias for resize()
void setAddressableSize(const label n) noexcept
Set addressed size to be inconsistent with allocated storage.
~DynamicList()
Destructor, sync allocated size before List destruction.
void resize_fill(const label len, const T &val)
Alter addressable size and set val for all addressed entries.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
void shrink_to_fit()
Shrink the allocated space to the number of elements used.
friend class List< T >
Declare friendship with the List class.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
label capacity() const noexcept
Size of the underlying storage.
static constexpr label min_size() noexcept
Normal lower capacity limit - the SizeMin template parameter.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
Istream & operator>>(Istream &, directionInfo &)
std::streamsize capacity_bytes() const noexcept
Number of contiguous bytes of the underlying storage.
void append(const T &val)
Copy append an element to the end of this list.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void setCapacity_unsafe(const label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
OBJstream os(runTime.globalPath()/outputName)
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void push_back(const T &val)
Copy append an element to the end of this list.
void swap(List< T > &list)
Swap with plain List content. Implies shrink_to_fit().
const Vector< label > N(dict.get< Vector< label >>("N"))
label push_uniq(const T &val)
Append an element if not already in the list.
T remove()
Remove and return the last element. Fatal on an empty list.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
void transfer(List< T > &list)
Transfer contents of the argument List into this.
void clearStorage()
Clear the list and delete storage.
label subset(const labelRange &range)
Retain a (start,size) subset from the list.
void reserve_exact(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
Foam::argList args(argc, argv)
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.