43 this->checkStart(
range.start());
84 Foam::Swap(this->
operator[](0), this->
operator[](i));
94 const label
upper = size()-1;
98 Foam::Swap(this->
operator[](i), this->
operator[](upper));
106 if (this->size_ != list.size_)
109 <<
"Lists have different sizes: " 110 << this->size_ <<
" != " << list.size() <<
nl 113 else if (this->size_ > 0)
118 std::copy(list.cbegin(), list.cend(), this->v_);
127 if (this->size_ != list.size())
130 <<
"Lists have different sizes: " 131 << this->size_ <<
" != " << list.size() <<
nl 134 else if (this->size_)
141 const label len = this->size_;
143 auto iter = this->v_;
145 for (label i = 0; i < len; (void)++i, (
void)++iter)
168 if constexpr (!is_contiguous_v<T>)
171 <<
"Invalid for non-contiguous data types" 174 return this->size_bytes();
181 const auto iter =
std::find(this->cbegin(), this->cend(), val);
182 return (iter != this->cend() ? label(iter - this->cbegin()) : label(-1));
189 if (
pos >= 0 && pos < this->size())
194 if (len > 0) len +=
pos;
195 if (len < 0 || len > this->size())
202 (this->cbegin() +
pos),
203 (this->cbegin() + len),
207 if (iter != (this->cbegin() + len))
209 return label(iter - this->cbegin());
222 if (pos < 0 || pos >= this->size())
224 pos = this->size()-1;
229 if (this->v_[
pos] == val)
251 (this->size_ == list.size_)
270 return std::lexicographical_compare
272 this->cbegin(), this->cend(),
281 return list.operator<(*this);
288 return !list.operator<(*this);
309 template<
class T,
class Compare>
310 void Foam::sort(UList<T>& list,
const Compare& comp)
313 std::sort(list.begin(), list.end(), comp);
321 std::stable_sort(list.begin(), list.end());
325 template<
class T,
class Compare>
329 std::stable_sort(list.begin(), list.end(), comp);
336 std::shuffle(list.begin(), list.end(), std::default_random_engine());
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant UList.
void swapLast(const label i)
Swap element with the last element. Fatal on an empty list.
void swapFirst(const label i)
Swap element with the first element. Fatal on an empty list.
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.
bool operator<=(const UList< T > &list) const
Return true if !(a > b). Takes linear time.
A range or interval of labels defined by a start and a size.
constexpr char nl
The newline '\n' character (0x0a)
void stableSort(UList< T > &list)
Stable sort the list.
labelRange validateRange(const labelRange &requestedRange) const
Return a validated (start,size) subset range, which means that it always addresses a valid section of...
bool operator<(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A older than B.
labelRange subset0(const label size) const
Calculate the intersection with the given 0/size range.
UList< T > & operator=(const UList< T > &)=delete
No copy assignment (default: shallow copy)
dimensionedScalar pos(const dimensionedScalar &ds)
void sort(UList< T > &list)
Sort the list.
bool operator==(const UList< T > &list) const
Equality operation on ULists of the same type.
bool operator!=(const UList< T > &list) const
The opposite of the equality operation. Takes linear time.
label rfind(const T &val, label pos=-1) const
Find index of the last occurrence of the value.
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...
label find(const T &val) const
Find index of the first occurrence of the value.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
bool operator<(const UList< T > &list) const
Compare two ULists lexicographically. Takes linear time.
void moveLast(const label i)
Move element to the last position.
std::streamsize byteSize() const
Number of contiguous bytes for the List data, runtime FatalError if type is not contiguous.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
void deepCopy(const UList< T > &list)
Copy elements of the given UList. Sizes must match!
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
void shuffle(UList< T > &list)
Randomise the list order.
void moveFirst(const label i)
Move element to the first position.
bool equal(const UList< Type1 > &a, const UList< Type2 > &b)
Test for list equality with different but compatible data types. Eg, int32 and int64.
bool operator>=(const UList< T > &list) const
Return true if !(a < b). Takes linear time.
bool operator>(const UList< T > &list) const
Compare two ULists lexicographically. Takes linear time.