Clingo
Loading...
Searching...
No Matches
Generic Algorithms

Generic algorithms used throughout the library. More...

Concepts

concept  CppClingo::Util::iterable
 Concept ensuring a collection is iterable.
 

Classes

class  CppClingo::Util::enumerate< T >
 A python style enumerate/range object. More...
 
class  CppClingo::Util::enumerate< T >
 A python style enumerate object. More...
 
class  CppClingo::Util::Graph
 Graph class to compute strongly connected components. More...
 

Functions

template<class Rng >
auto CppClingo::Util::copy_n (Rng const &rng, size_t n) -> std::vector< typename Rng::value_type >
 Return a vector with the first n elements from the given one.
 
template<class T , class... Ts>
auto CppClingo::Util::make_vec (Ts &&...args) -> std::vector< T >
 Avoids copies of initializer_lists.
 
template<class Container , std::input_iterator It, std::sentinel_for< It > Sent, typename Pred >
void CppClingo::Util::into_vec (Container &vec, It first, Sent last, Pred &&pred)
 Map a range into a vector using a transformation function.
 
template<class Container , class Rng , class Pred >
void CppClingo::Util::into_vec (Container &vec, Rng &&rng, Pred &&pred)
 Map a range into a vector using a transformation function.
 
template<class Container , std::input_iterator It, std::sentinel_for< It > Sent, typename Pred , typename... Args>
auto CppClingo::Util::to_vec (It begin, Sent end, Pred &&pred, Args &&...args)
 Use a transformation function to build a vector from a range.
 
template<template< class, class... > class Container = std::vector, std::ranges::input_range Rng, typename Pred , typename... Args>
auto CppClingo::Util::to_vec (Rng &&rng, Pred pred, Args &&...args)
 Use std::transform to build a vector.
 
template<class It , class Pred >
auto CppClingo::Util::transform_n (It begin, size_t n, Pred pred)
 Use std::transform to build a vector.
 
template<class Vec , class Pred >
auto CppClingo::Util::erase_if (Vec &vec, Pred pred) -> size_t
 Remove all elements from the vector matching the given predicate.
 
void CppClingo::Util::unreachable ()
 C++23's std::unreachable.
 
template<iterable U>
requires std::is_lvalue_reference_v<U>
 CppClingo::Util::enumerate (U &&x) -> enumerate< decltype(x.begin())>
 Deduction guide for iterables.
 
template<std::forward_iterator T>
 CppClingo::Util::enumerate (T begin, T end) -> enumerate< T >
 Deduction guide for forward iterators.
 
template<std::integral T>
 CppClingo::Util::enumerate (T end) -> enumerate< T >
 Deduction guide for integrals.
 
void CppClingo::Util::Graph::ensure_size (size_t n)
 Ensure that the graph holds at least n nodes.
 
void CppClingo::Util::Graph::add_edge (size_t u, size_t v)
 Add an edge to the graph.
 
auto CppClingo::Util::Graph::has_loop (size_t u) const -> bool
 Check if the given vertex has a loop.
 
template<class Callback >
void CppClingo::Util::Graph::tarjan (Callback cb)
 Compute the strongly connected components of the graph.
 

Detailed Description

Generic algorithms used throughout the library.

Function Documentation

◆ add_edge()

void CppClingo::Util::Graph::add_edge ( size_t  u,
size_t  v 
)
inline

Add an edge to the graph.

Nodes should be labeled consecutively.

◆ enumerate()

template<std::forward_iterator T>
CppClingo::Util::enumerate ( begin,
end 
) -> enumerate< T >

Deduction guide for forward iterators.

Deduction guide for integrals.

◆ has_loop()

auto CppClingo::Util::Graph::has_loop ( size_t  u) const -> bool
inline

Check if the given vertex has a loop.

Parameters
uthe vertex to check
Returns
whether the vertex has a loop

◆ tarjan()

template<class Callback >
void CppClingo::Util::Graph::tarjan ( Callback  cb)
inline

Compute the strongly connected components of the graph.

The components are reported in topological order.