54 return NullObjectRef<UList<T>>();
61 return (i == size()-1 ? 0 : i+1);
68 return (i ? i-1 : size()-1);
75 return this->operator[](this->fcIndex(i));
82 return this->operator[](this->fcIndex(i));
89 return this->operator[](this->rcIndex(i));
96 return this->operator[](this->rcIndex(i));
103 if (start < 0 || (start && start >= size_))
107 <<
"start " << start <<
" out of range [0," 117 if (size < 0 || size > size_)
120 <<
"size " << size <<
" out of range [0," 141 <<
"size " << len <<
" is negative, out of range [0," 145 this->checkStart(start);
146 this->checkSize(start + len);
152 this->checkSize(start);
163 <<
"attempt to access element " << i <<
" from zero sized list" 166 else if (i < 0 || i >= size_)
169 <<
"index " << i <<
" out of range [0," 179 const label len = size();
186 const T& val = (*this)[0];
188 for (label i = 1; i < len; ++i)
190 if (val != (*
this)[i])
203 return this->operator[](0);
210 return this->operator[](0);
217 return this->operator[](this->size()-1);
224 return this->operator[](this->size()-1);
245 return reinterpret_cast<const char*
>(v_);
252 return reinterpret_cast<char*
>(v_);
259 return std::streamsize(size_)*
sizeof(
T);
266 return (this->
find(val,
pos) >= 0);
287 if (i >= 0 && i < size_)
320 return *
reinterpret_cast<const List<T>*
>(
this);
352 return (v_ + (i < 0 ? 0 : size_ < i ? size_ : i));
359 return (v_ + (i < 0 ? 0 : size_ < i ? size_ : i));
366 return (v_ + (i < 0 ? 0 : size_ < i ? size_ : i));
449 std::swap(size_, list.size_);
450 std::swap(v_, list.v_);
459 const label nBy2 =
n/2;
461 for (label i = 0; i < nBy2; ++i)
bool contains(const T &val, label pos=0) const
Is the value contained in the list?
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse iterator (const access)
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant UList.
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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const_reverse_iterator crbegin() const
Return const_reverse_iterator to begin reverse traversing the UList.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
T & front()
Access first element of the list, position [0].
A traits class, which is primarily used for primitives.
T * iterator
Random access iterator for traversing a UList.
bool uniform() const
True if all entries have identical values, and list is non-empty.
void setAddressableSize(const label n) noexcept
Set addressed size to be inconsistent with allocated storage.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
const_reverse_iterator crend() const
Return const_reverse_iterator to end reverse traversing the UList.
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
T & operator[](const label i)
Return element of UList.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
reverse_iterator rbegin()
Return reverse_iterator to begin reverse traversing the UList.
reverse_iterator rend()
Return reverse_iterator to end reverse traversing the UList.
dimensionedScalar pos(const dimensionedScalar &ds)
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list)
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator (non-const access)
errorManip< error > abort(error &err)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
static const UList< T > & null()
Return a UList reference to a nullObject.
void checkRange(const label start, const label len) const
Check that start and length define a valid range.
constexpr UList() noexcept
Default construct, zero-sized and nullptr.
const T * const_iterator
Random access iterator for traversing a UList.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
T & back()
Access last element of the list, position [size()-1].
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
void checkSize(const label size) const
Check size is within valid range [0,size].
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
void shallowCopy(const UList< T > &list)
Copy the pointer and size held by the given UList.
iterator end() noexcept
Return an iterator to end traversing the UList.
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
constexpr auto begin(C &c) -> decltype(c.begin())
Return iterator to the beginning of the container c.
void checkStart(const label start) const
Check start is within valid range [0,size)
void checkIndex(const label i) const
Check index is within valid range [0,size)
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list)
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.