Contains algorithm.
More...
|
template<typename Container , typename T > |
bool | contains (const Container &container, const T &value) |
| Checks if a container contains a value. Shorthand for std::find.
|
|
template<typename It , typename Adjacent > |
void | topological_sort (It first, It last, Adjacent adjacent) |
| Topologically sorts a directed acyclic graph represented by a range and an adjacent function. Make sure that the graph is acyclic before calling this function. Use has_cycle to check for cycles.
|
|
template<typename It , typename Adjacent , typename OutputIt = std::nullptr_t> |
bool | has_cycle (It first, It last, Adjacent adjacent, OutputIt cycle_output=nullptr) |
| Checks if a graph represented by a range and an adjacent function has a cycle.
|
|
◆ contains()
template<typename Container , typename T >
bool engine::util::alg::contains |
( |
const Container & |
container, |
|
|
const T & |
value |
|
) |
| |
Checks if a container contains a value. Shorthand for std::find.
- Parameters
-
container | The container. |
value | The value to check. |
- Returns
- True if the container contains the value, false otherwise.
◆ topological_sort()
template<typename It , typename Adjacent >
void engine::util::alg::topological_sort |
( |
It |
first, |
|
|
It |
last, |
|
|
Adjacent |
adjacent |
|
) |
| |
Topologically sorts a directed acyclic graph represented by a range and an adjacent function. Make sure that the graph is acyclic before calling this function. Use has_cycle to check for cycles.
- Parameters
-
first | The first element of the range. |
last | The last element of the range. |
adjacent | The function that returns the adjacent elements for a given element. In a directed graph, this is the function that returns the successors of a given node. |
◆ has_cycle()
template<typename It , typename Adjacent , typename OutputIt = std::nullptr_t>
bool engine::util::alg::has_cycle |
( |
It |
first, |
|
|
It |
last, |
|
|
Adjacent |
adjacent, |
|
|
OutputIt |
cycle_output = nullptr |
|
) |
| |
Checks if a graph represented by a range and an adjacent function has a cycle.
- Parameters
-
first | The first element of the range. |
last | The last element of the range. |
adjacent | The function that returns the adjacent elements for a given element. In a directed graph, this is the function that returns the successors of a given node. |
cycle_output | The output iterator where the cycle is written. If not provided, the function returns true if a cycle is found, false otherwise. |
- Returns
- True if a cycle is found, false otherwise.