This page contains links to some classes and functions in libsemigroups
that extend the functionality of range objects from rx::ranges.
Please consult the rx::ranges README file for more information about ranges in general and the existing functionality of rx::ranges.
Range objects are used extensively elsewhere in libsemigroups
, and are returned by many functions.
- Note
- So that range classes in
libsemigroups
can be used efficiently with the functionality of rx::ranges, the usual naming conventions in libsemigroups
are not used for the member functions of range objects. In particular, none of the member functions required by rx::ranges check their arguments, but they do not have the suffix _no_checks
.
|
struct | Random |
| Aggregator for choosing a single random item in a range. More...
|
|
|
template<typename S, typename T> |
auto | chain (S const &x, T const &y) |
| Chain objects (const references).
|
|
template<typename T> |
auto | enumerate (T const &thing) |
| Enumerate an object (by const reference).
|
|
template<typename Range1, typename Range2> |
bool | equal (Range1 r1, Range2 r2) |
| Check two ranges for equality.
|
|
template<typename Range> |
bool | is_sorted (Range r) |
| Check if a range is sorted according to std::less.
|
|
template<typename Range, typename Compare> |
bool | is_sorted (Range r, Compare &&comp) |
| Check if a range is sorted according to comp .
|
|
template<typename Range1, typename Range2> |
bool | lexicographical_compare (Range1 r1, Range2 r2) |
| Check if a range is lexicographically less than another.
|
|
template<typename Range, typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>> |
std::ostream & | operator<< (std::ostream &os, Range r) |
| Insert a range into an output stream.
|
|
template<typename Range1, typename Range2> |
bool | shortlex_compare (Range1 r1, Range2 r2) |
| Check if a range is shortlex less than another.
|
|
◆ chain()
template<typename S, typename T>
auto chain |
( |
S const & | x, |
|
|
T const & | y ) |
Defined in ranges.hpp
.
This function is just a wrapper for rx::chain
but taking objects by reference rather than using iterators for convenience, and it returns a range objects where the items in x
come before any of the items in y
.
- Template Parameters
-
S | the type of the first argument. |
T | the type of the second argument. |
- Parameters
-
x | the first object to chain. |
y | the second object to chain. |
- Returns
- A range object.
◆ enumerate()
template<typename T>
auto enumerate |
( |
T const & | thing | ) |
|
Defined in ranges.hpp
.
This function is just a wrapper for rx::enumerate
but taking objects by reference rather than using iterators for convenience, and it returns a a pair consisting of the index of an item and that item. This is similar to the function of the same name in python.
- Template Parameters
-
T | the type of the argument. |
- Parameters
-
thing | the object to enumerate. |
- Returns
- A range object.
◆ equal()
template<typename Range1, typename Range2>
bool equal |
( |
Range1 | r1, |
|
|
Range2 | r2 ) |
Defined in ranges.hpp
.
This function checks if the ranges r1
and r2
are equal, in that they contain the same items (compared using operator==
) in the same order. This is analogous to std::equal.
- Template Parameters
-
Range1 | the type of the first range. |
Range2 | the type of the second range. |
- Parameters
-
r1 | the first range. |
r2 | the second range. |
- Returns
true
if the ranges are equal and false
if not.
◆ is_sorted() [1/2]
template<typename Range>
bool is_sorted |
( |
Range | r | ) |
|
Defined in ranges.hpp
.
This function checks if a range is sorted according to the comparison function object comp
, and is analogous to std::is_sorted.
- Template Parameters
-
Range | the type of the range to check for sortedness. |
- Parameters
-
- Returns
true
if the elements in the range are sorted in non-descending order according to std::less and false
otherwise.
- Note
- This function returns
true
for ranges of size 0
and 1
.
◆ is_sorted() [2/2]
template<typename Range, typename Compare>
bool is_sorted |
( |
Range | r, |
|
|
Compare && | comp ) |
Defined in ranges.hpp
.
This function checks if a range is sorted according to the comparison function object comp
, and is analogous to std::is_sorted.
- Template Parameters
-
Range | the type of the range to check for sortedness. |
Compare | the type of the comparison function object. |
- Parameters
-
r | the input range. |
comp | the comparison function object which returns true if the first argument is less than the second. |
- Returns
true
if the elements in the range are sorted in non-descending order according to comp
and false
otherwise.
- Note
- This function returns
true
for ranges of size 0
and 1
.
◆ lexicographical_compare()
template<typename Range1, typename Range2>
bool lexicographical_compare |
( |
Range1 | r1, |
|
|
Range2 | r2 ) |
Defined in ranges.hpp
.
This function checks if the range r1
is lexicographically less than the range r2
, using operator<
on the items in the ranges. This is analogous to std::lexicographical_compare.
- Template Parameters
-
Range1 | the type of the first range. |
Range2 | the type of the second range. |
- Parameters
-
r1 | the first range. |
r2 | the second range. |
- Returns
true
if the range r1
is lexicographically less than the range r2
, and false
it not.
◆ operator<<()
template<typename Range, typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
Defined in ranges.hpp
.
This function inserts a human readable representation of a range object into a std::ostream by applying std::to_string to each item in the range.
- Template Parameters
-
Range | the type of the range (must satisfy rx::is_input_or_sink_v<Range> ). |
- Parameters
-
os | the output stream. |
r | the range object. |
- Returns
- A reference to the first parameter
os
.
◆ shortlex_compare()
template<typename Range1, typename Range2>
bool shortlex_compare |
( |
Range1 | r1, |
|
|
Range2 | r2 ) |
Defined in ranges.hpp
.
This function checks if the range r1
is shortlex less than the range r2
, using operator<
on the items in the ranges. This is analogous to shortlex_compare.
- Template Parameters
-
Range1 | the type of the first range. |
Range2 | the type of the second range. |
- Parameters
-
r1 | the first range. |
r2 | the second range. |
- Returns
true
if the range r1
is shortlex less than the range r2
, and false
it not.