Clingo
Loading...
Searching...
No Matches
CppClingo::Control::TermBaseMap Class Reference

Map from symbols to show term ids. More...

#include <solver.hh>

Public Types

using Map = Util::ordered_map< SharedSymbol, prg_id_t >
 The container storing the mapping (internal).
 

Public Member Functions

template<class F >
auto add (Symbol sym, F &&fun) -> prg_id_t
 Add a new symbol to the map.
 
void add (Symbol sym, prg_id_t id)
 Add a symbol with the given id.
 
auto term_id (size_t i) const -> prg_id_t
 Get the id at the given index.
 
auto symbol (size_t i) const -> Symbol
 Get the symbol at the given index.
 
auto index (Symbol sym) const -> size_t
 Get the index of the symbol.
 
auto size () const -> size_t
 Get the number of mapped symbols.
 
auto begin () const -> Map::const_iterator
 Get an iterator over the symbol id pairs in the map pointing to the beginning of the sequence.
 
auto end () const -> Map::const_iterator
 Get an iterator over the symbol id pairs in the map pointing to the end of the sequence.
 

Detailed Description

Map from symbols to show term ids.

Member Function Documentation

◆ add() [1/2]

template<class F >
auto CppClingo::Control::TermBaseMap::add ( Symbol  sym,
F &&  fun 
) -> prg_id_t
inline

Add a new symbol to the map.

The given function is used to generate an id if the symbol is not contained in the map yet.

Parameters
symthe symbol
funthe id generator
Returns
the existing or new id

◆ add() [2/2]

void CppClingo::Control::TermBaseMap::add ( Symbol  sym,
prg_id_t  id 
)
inline

Add a symbol with the given id.

Throws a runtime error if such an id already exists.

Parameters
symthe symbol
idthe id

◆ begin()

auto CppClingo::Control::TermBaseMap::begin ( ) const -> Map::const_iterator
inline

Get an iterator over the symbol id pairs in the map pointing to the beginning of the sequence.

Returns
the iterator

◆ end()

auto CppClingo::Control::TermBaseMap::end ( ) const -> Map::const_iterator
inline

Get an iterator over the symbol id pairs in the map pointing to the end of the sequence.

Returns
the iterator

◆ index()

auto CppClingo::Control::TermBaseMap::index ( Symbol  sym) const -> size_t
inline

Get the index of the symbol.

This resulting index can be used to obtain the symbol and its id. The index itself is not the id of the symbol.

Parameters
symthe symbol
Returns
the index

◆ size()

auto CppClingo::Control::TermBaseMap::size ( ) const -> size_t
inline

Get the number of mapped symbols.

Returns
the number of mapped symbols

◆ symbol()

auto CppClingo::Control::TermBaseMap::symbol ( size_t  i) const -> Symbol
inline

Get the symbol at the given index.

Parameters
ithe index
Returns
the symbol

◆ term_id()

auto CppClingo::Control::TermBaseMap::term_id ( size_t  i) const -> prg_id_t
inline

Get the id at the given index.

Parameters
ithe index
Returns
the term id

The documentation for this class was generated from the following file: