42 #ifndef Foam_IntRange_H 43 #define Foam_IntRange_H 47 #include <type_traits> 57 template<
class T>
class List;
63 template<
class IntType>
66 static_assert(std::is_integral<IntType>::value,
"Integral required");
91 class const_reverse_iterator;
193 inline
void reset(const IntType beg, const IntType len)
noexcept;
226 inline const_iterator
at(
const IntType i)
const;
237 inline IntType operator++(
int)
noexcept;
240 inline IntType operator+=(const IntType
n)
noexcept;
243 inline IntType operator--()
noexcept;
244 inline IntType operator--(
int)
noexcept;
247 inline IntType operator-=(const IntType
n)
noexcept;
250 explicit operator
bool() const
noexcept {
return (size_ > 0); }
281 typedef std::random_access_iterator_tag iterator_category;
283 typedef IntType difference_type;
284 typedef const IntType* pointer;
285 typedef IntType reference;
291 explicit constexpr const_iterator(IntType val = 0)
noexcept 309 inline const_iterator operator++(
int)
noexcept;
312 inline const_iterator& operator--()
noexcept;
315 inline const_iterator operator--(
int)
noexcept;
318 inline const_iterator& operator+=(const IntType
n)
noexcept;
321 inline const_iterator& operator-=(const IntType
n)
noexcept;
324 inline constexpr const_iterator operator+
330 inline constexpr const_iterator operator-
336 inline constexpr IntType operator-
338 const const_iterator& iter
345 inline constexpr
bool operator==(const const_iterator& iter)
349 inline constexpr
bool operator<(const const_iterator& iter)
355 constexpr
bool operator!=(const const_iterator& iter)
358 return !(*
this == iter);
364 return !(iter < *
this);
370 return (iter < *
this);
376 return !(*
this < iter);
395 typedef const IntType*
pointer;
447 inline constexpr IntType operator-
469 return !(*
this == iter);
475 return !(iter < *
this);
481 return (iter < *
this);
487 return !(*
this < iter);
530 #if defined(WM_LABEL_SIZE) && (WM_LABEL_SIZE >= 64) 550 Ostream& operator<<(Ostream& os, const IntRange<int32_t>&
range);
553 Ostream& operator<<(Ostream& os, const IntRange<int64_t>&
range);
559 template<
class IntType>
560 inline constexpr
bool operator==
566 return (a.
start() ==
b.start() && a.
size() ==
b.size());
572 template<
class IntType>
573 inline constexpr
bool operator<
581 a.start() <
b.start()
584 !(
b.start() < a.start())
585 && a.size() <
b.size()
593 template<
class IntType>
594 inline constexpr
bool operator!=
603 template<
class IntType>
604 inline constexpr
bool operator<=
606 const IntRange<IntType>& a,
607 const IntRange<IntType>&
b 613 template<
class IntType>
614 inline constexpr
bool operator>
623 template<
class IntType>
624 inline constexpr
bool operator>=
constexpr bool operator>(const const_reverse_iterator &iter) const noexcept
Random-access input iterator with const access.
constexpr IntType operator[](const IntType i) const noexcept
Offset dereference, without bounds checking.
constexpr bool operator()(const Int val) const noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An interval of (signed) integers defined by a start and a size.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void setSize(const IntType n) noexcept
Change the size, no checks. Identical to resize()
void resize(const IntType n) noexcept
Change the size, no checks. Identical to setSize()
const_reverse_iterator crbegin() const noexcept
A const_reverse_iterator set to 1 before the end of range.
bool contains(const IntType value) const noexcept
True if the (global) value is within the range.
bool operator>(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A newer than B.
constexpr bool operator()(const Int val) const noexcept
const_reverse_iterator & operator++() noexcept
Prefix increment.
IntType rbegin_value() const noexcept
The max value of the range.
constexpr bool operator()(const Int val) const noexcept
IntType size_type
The type that can represent the size of the range.
const_reverse_iterator crend() const noexcept
A const_reverse_iterator set to 1 before the begin of range.
bool operator>=(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A same or newer than B.
constexpr const_reverse_iterator(IntType val=0) noexcept
Construct with specified value, or default construct.
IntType end_value() const noexcept
The value 1 beyond the end of the range.
void clampSize() noexcept
Enforce non-negative size.
Random-access reverse input iterator with const access.
Typedefs for label/uLabel without requiring label.H.
void clear() noexcept
Same as reset() - reset to zero start and zero size.
constexpr bool operator<=(const const_reverse_iterator &iter) const noexcept
IntType max() const noexcept
The (inclusive) upper value of the range, same as rbegin_value(). Ill-defined for an empty range...
bool good() const noexcept
True if range has size greater than zero.
bool operator<=(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A same or older than B.
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
std::random_access_iterator_tag iterator_category
constexpr bool operator()(const Int val) const noexcept
const_iterator begin() const noexcept
A const_iterator set to the beginning of the range.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
bool operator()(const IntType i) const noexcept
True if the global value is located within the range.
Istream & operator>>(Istream &, directionInfo &)
IntType value_type
Type of values the range contains.
const_iterator cend() const noexcept
A const_iterator set to 1 beyond the end of the range.
const_reverse_iterator rbegin() const noexcept
A const_reverse_iterator set to 1 before the end of range.
IntType start() const noexcept
The (inclusive) lower value of the range.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
IntType operator++() noexcept
Increase the size by 1.
const_iterator cbegin() const noexcept
A const_iterator set to the beginning of the range.
OBJstream os(runTime.globalPath()/outputName)
const_reverse_iterator rend() const noexcept
A const_reverse_iterator set to 1 before the begin of range.
const_iterator end() const noexcept
A const_iterator set to 1 beyond the end of the range.
const_iterator at(const IntType i) const
Return const_iterator to a position within the range, with bounds checking.
IntType begin_value() const noexcept
The value at the beginning of the range - same as min(), start()
bool empty() const noexcept
True if range is empty (zero-sized)
bool found(const IntType val) const noexcept
True if the (global) value is within the range.
IntType min() const noexcept
The (inclusive) lower value of the range, same as start(), begin_value()
constexpr bool operator>=(const const_reverse_iterator &iter) const noexcept
constexpr IntType operator[](const IntType n) const noexcept
Offset dereference operator.
IntType rend_value() const noexcept
The value 1 before the begin of range.
IntType size() const noexcept
The size of the range.
Unary predicate for less than 0 (int values)
void reset() noexcept
Reset to zero start and zero size.
constexpr IntType operator*() const noexcept
Return the value.
constexpr IntRange() noexcept
Default construct an empty range (0,0)
void setStart(const IntType i) noexcept
Set the start position, no checks.