84#ifndef Foam_UPtrList_H
85#define Foam_UPtrList_H
156 template<
class Compare>
169 return (a &&
b) ?
comp(*a, *
b) : !
b;
187 const T*
const a =
values.get(ai);
190 return (a &&
b) ? (*a < *
b) : !
b;
206 bool operator()(
const label ai,
const label bi)
const
208 const T*
const a =
values.get(ai);
211 return (a &&
b) ? (*
b < *a) : !a;
222 inline explicit
UPtrList(const label len);
267 inline const
T&
front() const;
273 inline const
T&
back() const;
278 inline const
T*
test(const label i) const;
283 inline const
T*
get(const label i) const;
288 inline
T*
get(const label i);
293 const
T*
set(const label i)
const {
return this->
get(i); }
306 inline void resize(
const label newLen);
332 inline T*
set(
const label i,
T* ptr);
352 inline const T&
at(
const label i)
const;
356 inline T&
at(
const label i);
372 const
T* operator()(const label i)
const {
return this->
get(i); }
401 template<
bool Const>
class Iterator;
404 friend class Iterator<true>;
407 friend class Iterator<false>;
422 std::conditional_t<Const, const UPtrList<T>,
UPtrList<T>>;
446 inline explicit Iterator(
list_type* list);
456 explicit operator const Iterator<Any>&()
const
458 return *
reinterpret_cast<const Iterator<Any>*
>(
this);
475 bool operator==(
const Iterator<Any>& iter)
const noexcept
477 return (
pos_ == iter.pos_);
483 return (
pos_ != iter.pos_);
493 class iterator :
public Iterator<false>
508 explicit iterator(const Iterator<false>& iter)
510 Iterator<false>(iter)
671template<
class T,
class Compare>
A rudimentary list of pointers used for PtrList, UPtrList, etc. This class is considered implementati...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Internally used base for iterator and const_iterator.
bool operator!=(const Iterator< Any > &iter) const noexcept
label pos_
The position within the list.
label key() const noexcept
The iterator position/index within the list.
bool good() const noexcept
True if iterator points to a non-null entry.
std::conditional_t< Const, const UPtrList< T >, UPtrList< T > > list_type
The list container type.
constexpr Iterator() noexcept
Default construct. Also the same as the end iterator.
list_type * list_
The parent being iterated.
bool operator==(const Iterator< Any > &iter) const noexcept
Compare hash-entry element pointers.
void increment()
Increment to the next non-null position.
Forward iterator with const access.
reference operator()() const
Legacy call operator: reference to the object.
const_iterator()=default
Default construct (end iterator).
const_iterator(const const_iterator &)=default
Copy construct.
const_iterator & operator=(const const_iterator &)=default
Copy assignment.
const_iterator & operator++()
Move to the next non-nullptr entry.
reference operator*() const
Reference to the object.
const_iterator(const iterator &iter)
Implicit conversion from dissimilar access type.
const_iterator(const Iterator< Any > &iter)
Copy construct from any access type.
reference val() const
Reference to the object.
pointer get() const
Pointer to the referenced object (failsafe).
pointer operator->() const
Pointer to the referenced object.
Forward iterator with non-const access.
reference operator()() const
Legacy call operator: reference to the object.
reference val() const
Reference to the object.
iterator & operator++()
Move to the next non-nullptr entry.
reference operator*() const
Reference to the object.
constexpr iterator() noexcept=default
Default construct - an end iterator.
pointer get() const
Pointer to the referenced object (failsafe).
pointer operator->() const
Pointer to the referenced object.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T & operator[](const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr....
T & at(const label i)
Return reference to the element at given position. FatalError for bounds problem or nullptr.
const const lduInterface * set(const label i) const
iterator begin()
Return iterator to begin traversal of non-nullptr entries.
void append(T *ptr)
Append an element to the end of the list.
void setSize(const label n)
const T & at(const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr.
T & first()
Reference to the first element of the list.
T ** begin_ptr() noexcept
Iterator to begin of raw pointers traversal (use with caution).
T value_type
Type of values the list contains.
void push_back(T *ptr)
Append an element to the end of the list.
void reorder(const labelUList &oldToNew, const bool check=false)
Reorder elements. Reordering must be unique (ie, shuffle).
bool empty() const noexcept
void operator=(const UPtrList< T > &list)
Copy assignment (shallow copies addresses).
Ostream & writeList(Ostream &os, const bool trimNull=false) const
Write UPtrList to Ostream, optionally ignoring null entries.
const lduInterface & back()
Ostream & printAddresses(Ostream &os) const
Print pointer addresses to Ostream (debugging only).
const const lduInterface * test(const label i) const
void append(UPtrList< T > &&other)
Move append another list to the end of this list.
void sortOrder(const labelUList &order, const bool check=false)
Reorder elements according to new order mapping (newToOld). Reordering must be unique (ie,...
T ** end_ptr() noexcept
Iterator beyond end of raw pointers traversal (use with caution).
UPtrList(Detail::PtrListDetail< T > &&ptrs) noexcept
Low-level move construct.
const T & last() const
Return reference to the last element of the list.
const_iterator cend() const noexcept
label capacity() const noexcept
const const lduInterface * get(const label i) const
label size() const noexcept
void push_back(UPtrList< T > &&other)
Move append another list to the end of this list.
T & reference
A non-const reference to the value_type.
const_iterator cbegin() const
const T & first() const
Return reference to first element of the list.
constexpr UPtrList() noexcept=default
Default construct.
const lduInterface & front()
FOAM_DEPRECATED_FOR(2022-09, "get(), set() or test() methods") const T *operator()(const label i) const
Deprecated(2022-09) - same as get().
void free()
Nullify all entries. Does not change the list size.
label count_nonnull() const noexcept
void resize_null(const label newLen)
Set the list to the given size and set all entries to nullptr.
label squeezeNull()
Squeeze out nullptr entries in the list of pointers after which any null pointers will be at the end ...
void transfer(UPtrList< T > &list)
Transfer contents into this list and annul the argument.
Detail::PtrListDetail< const lduInterface > ptrs_
void clear()
Set list size to zero.
void checkNonNull() const
Check and raise FatalError if any nullptr exists in the list.
T * set(const label i, T *ptr)
Set element to specified pointer and return the old list element, which can be a nullptr.
iterator end() noexcept
Return iterator beyond end of UPtrList traversal.
label find_next(label pos) const
The next non-null entry after the specified position.
void setAddressableSize(const label n) noexcept
Adjust addressable size.
T & operator[](const label i)
Return reference to the element at given position. FatalError for bounds problem or nullptr....
label count() const noexcept
T & last()
Return reference to the last element of the list.
void resize(const label newLen)
Change the size of the list. Any new entries are nullptr.
void swap(UPtrList< T > &list) noexcept
Swap content.
const T & const_reference
A const reference to the value_type.
void operator=(UPtrList< T > &&list)
Move assignment.
OBJstream os(runTime.globalPath()/outputName)
dimensionedScalar pos(const dimensionedScalar &ds)
static void check(const int retVal, const char *what)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void sort(UList< T > &list)
Sort the list.
UList< label > labelUList
A UList of labels.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
#define FOAM_DEPRECATED_FOR(since, replacement)
A UPtrList compare binary predicate for reverse sort order.
bool operator()(const label ai, const label bi) const
Compare dereferenced pointer locations for reverse sort.
greater(const UPtrList< T > &list)
const UPtrList< T > & values
A UPtrList compare binary predicate for normal sort order. Null entries (if any) sort to the end.
less(const UPtrList< T > &list)
bool operator()(const label ai, const label bi) const
Compare dereferenced pointer locations for normal sort.
const UPtrList< T > & values
A wrapper for a binary comparison of values that interjects pointer dereferencing with null pointer g...
value_compare(const Compare &cmp)
bool operator()(const T *const a, const T *const b) const
Compare dereferenced pointers.