34 ptrs_.setAddressableSize(
n);
41 return ptrs_.find_next(
pos);
57 ptrs_(std::move(ptrs))
71 ptrs_(std::move(list.ptrs_))
78 ptrs_(list.ptrs_, reuse)
94 const label len = ptrs_.size();
96 for (label i = 0; i < len; ++i)
98 ptrs_[i] = &(list[i]);
108 return ptrs_.empty();
122 return ptrs_.capacity();
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_);
225 ptrs_.transfer(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_);
289 ptrs_.checkNonNull();
333 pos_ = list_->find_next(-1);
354 return this->
good() ? this->
list_->get(this->
pos_) :
nullptr;
361 return this->list_->at(this->pos_);
389 return this->good() ? this->list_->get(this->pos_) :
nullptr;
396 return this->list_->at(this->pos_);
481 ptrs_.transfer(list.ptrs_);
reference val() const
Reference to the object.
list_type * list_
The parent being iterated.
const T & operator[](const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr...
const T * test(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
T & back()
Reference to the last element of the list.
void swap(UPtrList< T > &list) noexcept
Swap content.
iterator & operator++()
Move to the next non-nullptr entry.
A rudimentary list of pointers used for PtrList, UPtrList, etc. This class is considered implementati...
const_iterator & operator++()
Move to the next non-nullptr entry.
constexpr UPtrList() noexcept=default
Default construct.
const T * get(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
const T & at(const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr...
T & front()
Reference to the first element of the list.
Forward iterator with const access.
label pos_
The position within the list.
Forward iterator with non-const access.
label capacity() const noexcept
Size of the underlying storage.
dimensionedScalar pos(const dimensionedScalar &ds)
void free()
Nullify all entries. Does not change the list size.
void push_back(T *ptr)
Append an element to the end of the list.
label size() const noexcept
The number of entries in the list.
void checkNonNull() const
Check and raise FatalError if any nullptr exists in the list.
label count_nonnull() const noexcept
The number of non-nullptr entries in the list.
void transfer(UPtrList< T > &list)
Transfer contents into this list and annul the argument.
reference val() const
Reference to the object.
friend class Iterator< true >
Allow iterator access to internals.
void resize(const label newLen)
Change the size of the list. Any new entries are nullptr.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
pointer get() const
Pointer to the referenced object (failsafe)
void operator=(const UPtrList< T > &list)
Copy assignment (shallow copies addresses)
label find_next(label pos) const
The next non-null entry after the specified position.
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
iterator begin()
Return iterator to begin traversal of non-nullptr entries.
iterator end() noexcept
Return iterator beyond end of UPtrList traversal.
pointer get() const
Pointer to the referenced object (failsafe)
const_iterator cend() const noexcept
Return const_iterator beyond end of UPtrList traversal.
bool good() const noexcept
True if iterator points to a non-null entry.
void clear()
Set list size to zero.
const_iterator cbegin() const
Return const_iterator to begin traversal of non-nullptr entries.
void resize_null(const label newLen)
Set the list to the given size and set all entries to nullptr.
Detail::PtrListDetail< T > ptrs_
The list of pointers.
void setAddressableSize(const label n) noexcept
Adjust addressable size.
friend class Iterator< false >
Allow iterator access to internals.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...