A range is a conceptual container which does not contain any elements of its own, but is constructed from a begin iterator and an end iterator of another container.
More...
|
| | CRange (I begin, I end) |
| | Constructor.
|
| CRange< const_reverse_iterator > | reverse () const |
| | Create a range from reverse iterators.
|
template<class T>
requires (std::is_convertible_v<value_type, typename T::value_type>) |
| | operator T () const |
| | Implicit conversion to any container of value_type which supports push_back. This will copy elements.
|
| size_type | size () const |
| | Returns the number of elements in the range.
|
| const_reference | front () const |
| | Returns the element at the beginning of the range. Undefined if the range is empty.
|
| const_reference | frontOrDefault () const |
| | Returns the element at the beginning of the range, or a default value if the range is empty.
|
| value_type | frontOrDefault (value_type def) const |
| | Returns the element at the beginning of the range, or a default value if the range is empty.
|
| const_iterator | begin () const |
| | Begin and end iterators.
|
| const_iterator | cbegin () const |
| | Begin and end iterators.
|
| const_iterator | end () const |
| | Begin and end iterators.
|
| const_iterator | cend () const |
| | Begin and end iterators.
|
| const_reverse_iterator | rbegin () const |
| | Reverse begin and end iterators.
|
| const_reverse_iterator | crbegin () const |
| | Reverse begin and end iterators.
|
| const_reverse_iterator | rend () const |
| | Reverse begin and end iterators.
|
| const_reverse_iterator | crend () const |
| | Reverse begin and end iterators.
|
| template<class T> |
| T | to () const |
| | Explicit conversion to any container of value_type which supports push_back. This will copy elements.
|
| template<template< class... > class T> |
| auto | to () const |
| | Explicit conversion to any container of value_type which supports push_back. This will copy elements.
|
| bool | empty () const |
| | Returns true if the range is empty.
|
| bool | isEmpty () const |
| | Returns true if the range is empty.
|
| auto | transform (F function) const |
| | Return a new container generated by applying some transformation function to all elements of this one.
|
| auto | findBy (Predicate p) const |
| | Return a copy containing only those elements for which a given predicate returns true.
|
| const auto & | findFirstBy (Predicate p) const |
| | Return a reference to the first element for which a given predicate returns true. Undefined if there is none.
|
| auto | findFirstByOrDefault (Predicate p, const Value &def) const |
| | Return a copy of the first element for which a given predicate returns true, or a default value if there is none.
|
| bool | containsBy (Predicate p) const |
| | Return true if there is an element for which a given predicate returns true.
|
| bool | contains (const T &object) const |
| | Return true if there is an element equal to given object. Uses the most efficient implementation available in the derived container.
|
| bool | equalsBy (const T &other, Predicate c) const |
| | Return true if this container equals another container according to the given element equality predicate.
|
| bool | equalsByKeys (const T &other, Key0 k0, Keys... keys) const |
| | Return true if this container equals another container, considering only the given element members.
|
| T | randomElement () const |
| | Pick one random element.
|
| CRange< I > | randomElements (int n) const |
| | Copy n elements from the container at random.
|
| CRange< I > | sampleElements (int n) const |
| | Copy n elements from the container, randomly selected but evenly distributed.
|
template<class I>
class swift::misc::CRange< I >
A range is a conceptual container which does not contain any elements of its own, but is constructed from a begin iterator and an end iterator of another container.
By using iterator wrappers, it is possible to use CRange to iterate over the results of predicate methods without copying elements.
- Warning
- Remember that the iterators in the range refer to elements in the original container, so take care that the original container remains valid and does not invalidate its iterators during the lifetime of the range.
Definition at line 198 of file range.h.