swift
|
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...
Public Types | |
typedef std::iterator_traits< I >::value_type | value_type |
STL compatibility. | |
typedef std::iterator_traits< I >::reference | reference |
STL compatibility. | |
typedef std::iterator_traits< I >::difference_type | difference_type |
STL compatibility. | |
typedef const value_type & | const_reference |
STL compatibility. | |
typedef value_type | key_type |
STL compatibility. | |
typedef difference_type | size_type |
STL compatibility. | |
typedef I | iterator |
STL compatibility. | |
typedef I | const_iterator |
STL compatibility. | |
typedef std::reverse_iterator< I > | reverse_iterator |
STL compatibility. | |
typedef std::reverse_iterator< I > | const_reverse_iterator |
STL compatibility. | |
Public Member Functions | |
CRange (I begin, I end) | |
Constructor. | |
CRange< const_reverse_iterator > | reverse () const |
Create a range from reverse iterators. | |
template<class T , class = std::enable_if_t<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. | |
auto | findBy (K0 k0, V0 v0, KeysValues... keysValues) const |
Return a copy containing only those elements matching some particular key/value pair(s). More... | |
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. | |
const auto & | findFirstBy (K key, V value) const |
Return a reference to the first element matching some particular key/value pair(s). 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. | |
auto | findFirstByOrDefault (Predicate p) const |
Return a copy of the first element for which a given predicate returns true, or a default value if there is none. | |
auto | findFirstByOrDefault (K key, V value, const Value &def) const |
Return a copy of the first element matching some particular key/value pair(s), or a default value if there is none. | |
auto | findFirstByOrDefault (K T::*key, V value) const |
Return a copy of the first element matching some particular key/value pair(s), 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 | contains (K0 k0, V0 v0, KeysValues... keysValues) const |
Return a copy containing only those elements matching some particular key/value pair(s). More... | |
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. | |
Additional Inherited Members | |
![]() | |
static bool | equalPointers (const T *a, const U *b) |
Efficiently compare addresses of two objects. Return false if types are not compatible. | |
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.