A list of unary predicates (tests) on scalars. Includes a number of standard comparison predicates (eg, "less", "greater", ...). More...
#include <scalarPredicates.H>


Public Types | |
| enum | opType { EQUAL , NOT_EQUAL , LESS , LESS_EQUAL , GREATER , GREATER_EQUAL , ALWAYS , NEVER , LESS_EQ = LESS_EQUAL , GREATER_EQ = GREATER_EQUAL } |
| Enumerations for some standard comparison predicates. More... | |
| typedef std::function< bool(Foam::scalar)> | unary |
| The unary function type for testing a scalar. | |
| Public Types inherited from List< std::function< bool(Foam::scalar)> > | |
| typedef SubList< std::function< bool(Foam::scalar)> > | subList |
| Declare type of subList. | |
| Public Types inherited from UList< std::function< bool(Foam::scalar)> > | |
| typedef std::function< bool(Foam::scalar)> | value_type |
| The value type the list contains. | |
| typedef std::function< bool(Foam::scalar)> * | pointer |
| The pointer type for non-const access to value_type items. | |
| typedef const std::function< bool(Foam::scalar)> * | const_pointer |
| The pointer type for const access to value_type items. | |
| typedef std::function< bool(Foam::scalar)> & | reference |
| The type used for storing into value_type objects. | |
| typedef const std::function< bool(Foam::scalar)> & | const_reference |
| The type used for reading from constant value_type objects. | |
| typedef std::function< bool(Foam::scalar)> * | iterator |
| Random access iterator for traversing a UList. | |
| typedef const std::function< bool(Foam::scalar)> * | const_iterator |
| Random access iterator for traversing a UList. | |
| typedef label | size_type |
| The type to represent the size of a UList. | |
| typedef label | difference_type |
| The difference between iterator objects. | |
| typedef std::reverse_iterator< iterator > | reverse_iterator |
| Reverse iterator (non-const access). | |
| typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
| Reverse iterator (const access). | |
| using | is_List |
| Have unique tag. | |
Public Member Functions | |
| scalars (std::initializer_list< std::pair< word, scalar > > entries) | |
| Construct from an initializer list of (opName opValue) tuples. | |
| scalars (const UList< Tuple2< word, scalar > > &entries) | |
| Copy construct from a list of (opName opValue) tuples. | |
| scalars (Istream &is) | |
| Construct from Istream, from list of (opName opValue) tuples. | |
| ~scalars ()=default | |
| Destructor. | |
| void | assign (std::initializer_list< std::pair< word, scalar > > entries) |
| Assign new predicates from an initializer list of (opName opValue) tuples. | |
| void | assign (const UList< Tuple2< word, scalar > > &entries) |
| Assign new predicates from a list of (opName opValue) tuples. | |
| label | find (const scalar value, label pos=0) const |
| Index of the first matching test for the value. | |
| label | rfind (const scalar value, label pos=-1) const |
| Index of the last match for the value. | |
| bool | contains (const scalar value, label pos=0) const |
| Matches any condition in the list after the offset position. | |
| bool | match (const scalar value) const |
| Matches any condition in the list. | |
| bool | matchAny (const scalar value) const |
| Matches any condition in the list. | |
| bool | matchAll (const scalar value) const |
| Matches all conditions in the list. | |
| labelList | matching (const scalar value) const |
| Extract list indices for all matches. | |
| labelList | matching (const UList< scalar > &input, const bool invert=false) const |
| Extract list indices for all matches. | |
| bool | operator() (const scalar value) const |
| Identical to contains(), match(), for use as a predicate. | |
| bool | found (const scalar value, label pos=0) const |
| Same as contains(). | |
| Public Member Functions inherited from List< std::function< bool(Foam::scalar)> > | |
| void | resize (const label len) |
| autoPtr< List< std::function< bool(Foam::scalar)> > > | clone () const |
| Clone. | |
| ~List () | |
| Destructor. | |
| void | clear () |
| Clear the list, i.e. set size to zero. | |
| void | resize_copy (label count, const label len) |
| Change allocated size of list, retaining the first count elements. | |
| void | resize_fill (const label len, const std::function< bool(Foam::scalar)> &val) |
| Adjust allocated size of list and set val for all elements. | |
| void | resize_nocopy (const label len) |
| Adjust allocated size of list without necessarily. | |
| void | transfer (List< std::function< bool(Foam::scalar)> > &list) |
| Transfer the contents of the argument List into this list and annul the argument list. | |
| std::function< bool(Foam::scalar)> & | newElmt (const label i) |
| Return subscript-checked element of UList and resizing the list if required. | |
| std::function< bool(Foam::scalar)> & | emplace_back (Args &&... args) |
| Construct an element at the end of the list, return reference to the new list element. | |
| void | push_back (const std::function< bool(Foam::scalar)> &val) |
| Append an element at the end of the list. | |
| label | push_uniq (const std::function< bool(Foam::scalar)> &val) |
| Append an element if not already in the list. | |
| void | pop_back (label n=1) |
| Reduce size by 1 or more elements. Can be called on an empty list. | |
| void | operator= (const UList< std::function< bool(Foam::scalar)> > &list) |
| Assignment to UList operator. Takes linear time. | |
| Istream & | readList (Istream &is) |
| Read List from Istream, discarding contents of existing List. | |
| void | shallowCopy (const UList< std::function< bool(Foam::scalar)> > &)=delete |
| No shallowCopy permitted. | |
| bool | set (const label i, bool val=true) |
| A bitSet::set() method for a list of bool. | |
| void | append (const std::function< bool(Foam::scalar)> &val) |
| Append an element at the end of the list. | |
| label | appendUniq (const std::function< bool(Foam::scalar)> &val) |
| Same as push_uniq(). | |
| void | setSize (label n) |
| Alias for resize(). | |
| Public Member Functions inherited from UList< std::function< bool(Foam::scalar)> > | |
| UList (const UList< std::function< bool(Foam::scalar)> > &) noexcept=default | |
| Copy construct, shallow copy. | |
| UList< std::function< bool(Foam::scalar)> > & | operator= (const UList< std::function< bool(Foam::scalar)> > &)=delete |
| No copy assignment (default: shallow copy). | |
| 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 list. | |
| 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 of the list. | |
| const std::function< bool(Foam::scalar)> & | fcValue (const label i) const |
| Return forward circular value (ie, next value in the list). | |
| const std::function< bool(Foam::scalar)> & | rcValue (const label i) const |
| Return reverse circular value (ie, previous value in the list). | |
| const std::function< bool(Foam::scalar)> * | cdata () const noexcept |
| Return pointer to the underlying array serving as data storage. | |
| std::function< bool(Foam::scalar)> * | data () noexcept |
| Return pointer to the underlying array serving as data storage. | |
| const char * | cdata_bytes () const noexcept |
| Return pointer to the underlying array serving as data storage,. | |
| char * | data_bytes () noexcept |
| Return pointer to the underlying array serving as data storage,. | |
| std::function< bool(Foam::scalar)> & | front () |
| Access first element of the list, position [0]. | |
| std::function< bool(Foam::scalar)> & | back () |
| Access last element of the list, position [size()-1]. | |
| std::streamsize | size_bytes () const noexcept |
| Number of contiguous bytes for the List data. | |
| std::streamsize | byteSize () const |
| Number of contiguous bytes for the List data, runtime FatalError if type is not contiguous. | |
| void | checkStart (const label start) const |
| Check start is within valid range [0,size). | |
| void | checkSize (const label size) const |
| Check size is within valid range [0,size]. | |
| void | checkRange (const label start, const label len) const |
| Check that start and length define a valid range. | |
| void | checkIndex (const label i) const |
| Check index is within valid range [0,size). | |
| bool | uniform () const |
| True if all entries have identical values, and list is non-empty. | |
| bool | contains (const std::function< bool(Foam::scalar)> &val) const |
| True if the value is contained in the list. | |
| label | find (const std::function< bool(Foam::scalar)> &val) const |
| Find index of the first occurrence of the value. | |
| label | rfind (const std::function< bool(Foam::scalar)> &val, label pos=-1) const |
| Find index of the last occurrence of the value. | |
| void | moveFirst (const label i) |
| Move element to the first position. | |
| void | moveLast (const label i) |
| Move element to the last position. | |
| void | swapFirst (const label i) |
| Swap element with the first element. Fatal on an empty list. | |
| void | swapLast (const label i) |
| Swap element with the last element. Fatal on an empty list. | |
| void | shallowCopy (std::function< bool(Foam::scalar)> *__restrict__ ptr, const label len) noexcept |
| Copy the pointer and size. | |
| void | deepCopy (const UList< std::function< bool(Foam::scalar)> > &list) |
| Copy elements of the given UList. Sizes must match! | |
| SubList< std::function< bool(Foam::scalar)> > | slice (const label pos, label len=-1) |
| Return SubList slice (non-const access) - no range checking. | |
| std::function< bool(Foam::scalar)> & | operator[] (const label i) |
| Return element of UList. | |
| operator const Foam::List< std::function< bool(Foam::scalar)> > & () const | |
| Allow cast to a const List<T>&. | |
| iterator | begin () noexcept |
| Return an iterator to begin traversing the UList. | |
| iterator | end () noexcept |
| Return an iterator to end traversing the UList. | |
| const_iterator | cbegin () const noexcept |
| Return const_iterator to begin traversing the constant UList. | |
| const_iterator | cend () const noexcept |
| Return const_iterator to end traversing the constant UList. | |
| reverse_iterator | rbegin () |
| Return reverse_iterator to begin reverse traversing the UList. | |
| reverse_iterator | rend () |
| Return reverse_iterator to end reverse traversing the UList. | |
| const_reverse_iterator | crbegin () const |
| Return const_reverse_iterator to begin reverse traversing the UList. | |
| const_reverse_iterator | crend () const |
| Return const_reverse_iterator to end reverse traversing the UList. | |
| bool | empty () const noexcept |
| True if List is empty (ie, size() is zero). | |
| label | capacity () const noexcept |
| Size of the underlying storage. | |
| void | swap (UList< std::function< bool(Foam::scalar)> > &list) noexcept |
| Swap content with another UList of the same type in constant time. | |
| bool | operator== (const UList< std::function< bool(Foam::scalar)> > &list) const |
| Equality operation on ULists of the same type. | |
| bool | operator!= (const UList< std::function< bool(Foam::scalar)> > &list) const |
| The opposite of the equality operation. Takes linear time. | |
| bool | operator< (const UList< std::function< bool(Foam::scalar)> > &list) const |
| Compare two ULists lexicographically. Takes linear time. | |
| bool | operator> (const UList< std::function< bool(Foam::scalar)> > &list) const |
| Compare two ULists lexicographically. Takes linear time. | |
| bool | operator<= (const UList< std::function< bool(Foam::scalar)> > &list) const |
| Return true if !(a > b). Takes linear time. | |
| bool | operator>= (const UList< std::function< bool(Foam::scalar)> > &list) const |
| Return true if !(a < b). Takes linear time. | |
| Istream & | readList (Istream &is) |
| Read List contents from Istream. | |
| Ostream & | writeList (Ostream &os, const label shortLen=0) const |
| Write List, with line-breaks in ASCII when length exceeds shortLen. | |
| bool | all () const |
| True if all entries are 'true' or if the list is empty. | |
| bool | any () const |
| True if any entries are 'true'. | |
| bool | none () const |
| True if no entries are 'true'. | |
| bool | test (const label i) const |
Test bool value at specified position, always false for out-of-range access. | |
| bool | get (const label i) const |
Return bool value at specified position, always false for out-of-range access. | |
| bool | unset (const label i) |
Unset the bool entry at specified position, always false for out-of-range access. | |
| std::string_view | view () const |
| Return a string_view of the charList. Content is non-modifiable. | |
| std::function< bool(Foam::scalar)> & | first () |
| Access first element of the list, position [0]. | |
| std::function< bool(Foam::scalar)> & | last () |
| Access last element of the list, position [size()-1]. | |
| bool | found (const std::function< bool(Foam::scalar)> &val, label pos=0) const |
| Same as contains(). | |
| auto | expr () const |
| Wrap value as expression. | |
Static Public Member Functions | |
| static unary | equalOp (const scalar opVal, const scalar tol=VSMALL) |
| Compare for equality, with specified tolerance (non-negative). | |
| static unary | notEqualOp (const scalar opVal, const scalar tol=VSMALL) |
| Compare for inequality, with specified tolerance (non-negative). | |
| static unary | lessOp (const scalar opVal) |
| Test if value is 'less' than prescribed. | |
| static unary | lessEqualOp (const scalar opVal) |
| Test if value is 'less_equal' to prescribed. | |
| static unary | greaterOp (const scalar opVal) |
| Test if value is 'greater' than prescribed Compare scalar values for inequality. | |
| static unary | greaterEqualOp (const scalar opVal) |
| Test if value is 'greater_equal' to prescribed. | |
| static unary | trueOp () |
| Predicate that always returns true. | |
| static unary | falseOp () |
| Predicate that always returns false. | |
| static unary | andOp (const unary &test1, const unary &test2) |
| Combine unary tests as an AND operation. | |
| static unary | orOp (const unary &test1, const unary &test2) |
| Combine unary tests as an OR operation. | |
| static unary | operation (const opType op, const scalar opVal, const scalar tol=VSMALL) |
| Standard comparison method by type. | |
| static unary | operation (const word &opName, const scalar opVal, const scalar tol=VSMALL) |
| Standard comparison method by name. | |
| static unary | operation (const Tuple2< word, scalar > &op, const scalar tol=VSMALL) |
| Standard comparison method by (name, value). | |
| static unary | operation (const std::pair< word, scalar > &op, const scalar tol=VSMALL) |
| Standard comparison method by (name, value). | |
| Static Public Member Functions inherited from List< std::function< bool(Foam::scalar)> > | |
| static const List< std::function< bool(Foam::scalar)> > & | null () noexcept |
| Return a null List (reference to a nullObject). Behaves like an empty List. | |
| Static Public Member Functions inherited from UList< std::function< bool(Foam::scalar)> > | |
| static const UList< std::function< bool(Foam::scalar)> > & | null () noexcept |
| Return a null UList (reference to a nullObject). Behaves like an empty UList. | |
| static constexpr label | max_size () noexcept |
| The size of the largest possible UList. | |
Static Public Attributes | |
| static const Enum< opType > | opNames |
| Names for the opType enumeration. | |
Additional Inherited Members | |
| Protected Member Functions inherited from UList< std::function< bool(Foam::scalar)> > | |
| void | setAddressableSize (const label n) noexcept |
| Set addressed size to be inconsistent with allocated storage. | |
| void | size (const label n) |
| Older name for setAddressableSize. | |
| void | writeEntry (Ostream &os) const |
| Write the UList with its compound type. | |
| labelRange | validateRange (const labelRange &requestedRange) const |
| Return a validated (start,size) subset range, which means that it always addresses a valid section of the list. | |
| void | fill_uniform (const std::function< bool(Foam::scalar)> &val) |
| Assign all entries to the given value. | |
A list of unary predicates (tests) on scalars. Includes a number of standard comparison predicates (eg, "less", "greater", ...).
Definition at line 62 of file scalarPredicates.H.
| typedef std::function<bool(Foam::scalar)> unary |
The unary function type for testing a scalar.
Definition at line 73 of file scalarPredicates.H.
| enum opType |
Enumerations for some standard comparison predicates.
Definition at line 78 of file scalarPredicates.H.
|
explicit |
Construct from an initializer list of (opName opValue) tuples.
Definition at line 176 of file scalarPredicates.C.
References assign().

Copy construct from a list of (opName opValue) tuples.
Definition at line 185 of file scalarPredicates.C.
References assign(), and UList< std::function< bool(Foam::scalar)> >::UList().

|
explicit |
Construct from Istream, from list of (opName opValue) tuples.
Definition at line 194 of file scalarPredicates.C.
|
default |
Destructor.
References Foam::invert(), Foam::pos(), and UList< std::function< bool(Foam::scalar)> >::UList().

|
inlinestatic |
Compare for equality, with specified tolerance (non-negative).
Definition at line 105 of file scalarPredicates.H.
References Foam::mag().

|
inlinestatic |
Compare for inequality, with specified tolerance (non-negative).
Definition at line 121 of file scalarPredicates.H.
References Foam::mag().

|
inlinestatic |
Test if value is 'less' than prescribed.
Definition at line 137 of file scalarPredicates.H.
|
inlinestatic |
Test if value is 'less_equal' to prescribed.
Definition at line 149 of file scalarPredicates.H.
|
inlinestatic |
Test if value is 'greater' than prescribed Compare scalar values for inequality.
Definition at line 162 of file scalarPredicates.H.
|
inlinestatic |
Test if value is 'greater_equal' to prescribed.
Definition at line 174 of file scalarPredicates.H.
|
inlinestatic |
Predicate that always returns true.
Definition at line 188 of file scalarPredicates.H.
|
inlinestatic |
Predicate that always returns false.
Definition at line 196 of file scalarPredicates.H.
Combine unary tests as an AND operation.
Definition at line 207 of file scalarPredicates.H.
Referenced by parcelSelection::calculateFilter().

Combine unary tests as an OR operation.
Definition at line 218 of file scalarPredicates.H.
Referenced by parcelSelection::calculateFilter().

Standard comparison method by type.
References UList< std::function< bool(Foam::scalar)> >::UList().
Referenced by assign(), assign(), parcelSelection::calculateFilter(), operation(), operation(), and operation().


|
inlinestatic |
Standard comparison method by name.
Definition at line 23 of file scalarPredicatesI.H.
References operation(), and opNames.

|
inlinestatic |
Standard comparison method by (name, value).
Definition at line 34 of file scalarPredicatesI.H.
References Tuple2< T1, T2 >::first(), operation(), opNames, and Tuple2< T1, T2 >::second().

|
inlinestatic |
Standard comparison method by (name, value).
Definition at line 44 of file scalarPredicatesI.H.
References operation(), and opNames.

| void assign | ( | std::initializer_list< std::pair< word, scalar > > | entries | ) |
Assign new predicates from an initializer list of (opName opValue) tuples.
Definition at line 202 of file scalarPredicates.C.
References UList< std::function< bool(Foam::scalar)> >::begin(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::hasBadEntries(), operation(), Foam::printBadEntries(), and List< std::function< bool(Foam::scalar)> >::resize_nocopy().
Referenced by Foam::operator>>(), scalars(), and scalars().


Assign new predicates from a list of (opName opValue) tuples.
Definition at line 232 of file scalarPredicates.C.
References UList< std::function< bool(Foam::scalar)> >::begin(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::hasBadEntries(), operation(), Foam::printBadEntries(), List< std::function< bool(Foam::scalar)> >::resize_nocopy(), and UList< std::function< bool(Foam::scalar)> >::UList().

| Foam::label find | ( | const scalar | value, |
| label | pos = 0 ) const |
Index of the first matching test for the value.
Any occurrences before the start pos are ignored. Linear search.
Definition at line 262 of file scalarPredicates.C.
References Foam::pos(), and UList< std::function< bool(Foam::scalar)> >::size().
Referenced by contains().


| Foam::label rfind | ( | const scalar | value, |
| label | pos = -1 ) const |
Index of the last match for the value.
Any occurrences after the end pos are ignored. Linear search.
Definition at line 289 of file scalarPredicates.C.
References Foam::pos(), and UList< std::function< bool(Foam::scalar)> >::size().

|
inline |
Matches any condition in the list after the offset position.
Linear search from start pos until the end of the list. Any occurrences before the start pos are ignored.
Definition at line 56 of file scalarPredicatesI.H.
References find(), and Foam::pos().
Referenced by found().


|
inline |
Matches any condition in the list.
Definition at line 66 of file scalarPredicatesI.H.
References matchAny().

|
inline |
Matches any condition in the list.
Definition at line 72 of file scalarPredicatesI.H.
Referenced by match(), matching(), and operator()().

|
inline |
Matches all conditions in the list.
Definition at line 86 of file scalarPredicatesI.H.
References UList< std::function< bool(Foam::scalar)> >::empty().

|
inline |
Extract list indices for all matches.
Definition at line 100 of file scalarPredicatesI.H.
References List< T >::resize(), and UList< std::function< bool(Foam::scalar)> >::size().

|
inline |
Extract list indices for all matches.
| input | A list of scalar inputs to test |
| invert | invert the matching logic |
Definition at line 123 of file scalarPredicatesI.H.
References Foam::invert(), matchAny(), List< T >::resize(), UList< T >::size(), and UList< std::function< bool(Foam::scalar)> >::UList().

|
inline |
Identical to contains(), match(), for use as a predicate.
Definition at line 397 of file scalarPredicates.H.
References matchAny().

|
inline |
Same as contains().
Definition at line 405 of file scalarPredicates.H.
References contains(), and Foam::pos().

|
static |
Names for the opType enumeration.
Definition at line 97 of file scalarPredicates.H.
Referenced by Foam::hasBadEntries(), operation(), operation(), operation(), and Foam::printBadEntries().