matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Loading...
Searching...
No Matches
Functions
engine::util::alg Namespace Reference

Contains algorithm. More...

Functions

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.
 

Detailed Description

Contains algorithm.

Function Documentation

◆ 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
containerThe container.
valueThe 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
firstThe first element of the range.
lastThe last element of the range.
adjacentThe 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
firstThe first element of the range.
lastThe last element of the range.
adjacentThe 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_outputThe 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.