44 this->checkStart(
range.start());
85 Foam::Swap(this->
operator[](0), this->
operator[](i));
95 const label
upper = size()-1;
99 Foam::Swap(this->
operator[](i), this->
operator[](upper));
107 if (this->size_ != list.size_)
110 <<
"Lists have different sizes: " 111 << this->size_ <<
" != " << list.size() <<
nl 114 else if (this->size_ > 0)
119 std::copy(list.cbegin(), list.cend(), this->v_);
128 if (this->size_ != list.size())
131 <<
"Lists have different sizes: " 132 << this->size_ <<
" != " << list.size() <<
nl 135 else if (this->size_)
142 const label len = this->size_;
144 auto iter = this->v_;
146 for (label i = 0; i < len; (void)++i, (
void)++iter)
169 if (!is_contiguous<T>::value)
172 <<
"Invalid for non-contiguous data types" 175 return this->size_bytes();
183 return (iter != this->
cend() ? label(iter - this->
cbegin()) : label(-1));
190 if (
pos >= 0 && pos < this->size())
195 if (len > 0) len +=
pos;
196 if (len < 0 || len > this->size())
208 if (iter != (this->
cbegin() + len))
210 return label(iter - this->
cbegin());
223 if (pos < 0 || pos >= this->size())
225 pos = this->size()-1;
230 if (this->v_[
pos] == val)
252 (this->size_ == list.size_)
271 return std::lexicographical_compare
282 return list.operator<(*this);
289 return !list.operator<(*this);
310 template<
class T,
class Compare>
311 void Foam::sort(UList<T>& list,
const Compare& comp)
314 std::sort(list.begin(), list.end(), comp);
322 std::stable_sort(list.begin(), list.end());
326 template<
class T,
class Compare>
330 std::stable_sort(list.begin(), list.end(), comp);
337 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)
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
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.
constexpr auto cend(const C &c) -> decltype(c.end())
Return const_iterator to the end of the container c.
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.
constexpr auto cbegin(const C &c) -> decltype(c.begin())
Return const_iterator to the beginning of the container c.
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.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
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().
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 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.