34 ptrs_.setAddressableSize(
n);
57 ptrs_(std::move(ptrs))
71 ptrs_(std::move(list.ptrs_))
94 const label len =
ptrs_.size();
96 for (label i = 0; i < len; ++i)
98 ptrs_[i] = &(list[i]);
108 return ptrs_.empty();
129 return ptrs_.count_nonnull();
157 const T* ptr = ptrs_.get(i);
162 <<
"Cannot dereference nullptr at index " << i
163 <<
" in range [0," << size() <<
")\n"
174 T* ptr = ptrs_.get(i);
179 <<
"Cannot dereference nullptr at index " << i
180 <<
" in range [0," << size() <<
")\n"
218 ptrs_.swap(list.ptrs_);
246 return this->
at(this->
size()-1);
253 return this->
at(this->
size()-1);
260 ptrs_.resize(newLen);
267 ptrs_.resize_null(newLen);
274 ptrs_.push_back(ptr);
281 ptrs_.push_back(other.ptrs_);
344 pos_ = list_->find_next(pos_);
354 return this->
good() ? this->
list_->get(this->
pos_) :
nullptr;
378 iterator iter(*
this);
389 return this->
good() ? this->
list_->get(this->
pos_) :
nullptr;
481 ptrs_.transfer(list.ptrs_);
A rudimentary list of pointers used for PtrList, UPtrList, etc. This class is considered implementati...
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.
label pos_
The position within the list.
bool good() const noexcept
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.
void increment()
Increment to the next non-null position.
Forward iterator with const access.
const_iterator()=default
Default construct (end iterator).
const_iterator & operator++()
Move to the next non-nullptr entry.
reference val() const
Reference to the object.
pointer get() const
Pointer to the referenced object (failsafe).
Forward iterator with non-const access.
reference val() const
Reference to the object.
iterator & operator++()
Move to the next non-nullptr entry.
constexpr iterator() noexcept=default
Default construct - an end iterator.
pointer get() const
Pointer to the referenced object (failsafe).
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....
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
iterator begin()
Return iterator to begin traversal of non-nullptr entries.
const T & at(const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr.
void push_back(T *ptr)
Append an element to the end of the list.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
void operator=(const UPtrList< T > &list)
Copy assignment (shallow copies addresses).
T & back()
Reference to the last element of the list.
const T * test(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
UPtrList(Detail::PtrListDetail< T > &&ptrs) noexcept
Low-level move construct.
const_iterator cend() const noexcept
Return const_iterator beyond end of UPtrList traversal.
label capacity() const noexcept
Size of the underlying storage.
const T * get(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
label size() const noexcept
The number of entries in the list.
const_iterator cbegin() const
Return const_iterator to begin traversal of non-nullptr entries.
constexpr UPtrList() noexcept=default
Default construct.
T & front()
Reference to the first element of the list.
void free()
Nullify all entries. Does not change the list size.
label count_nonnull() const noexcept
The number of non-nullptr entries in the list.
void resize_null(const label newLen)
Set the list to the given size and set all entries to nullptr.
void transfer(UPtrList< T > &list)
Transfer contents into this list and annul the argument.
Detail::PtrListDetail< T > ptrs_
The list of pointers.
void clear()
Set list size to zero.
void checkNonNull() const
Check and raise FatalError if any nullptr exists in the list.
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.
void resize(const label newLen)
Change the size of the list. Any new entries are nullptr.
void swap(UPtrList< T > &list) noexcept
Swap content.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedScalar pos(const dimensionedScalar &ds)
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)