Clingo
Loading...
Searching...
No Matches
Clingo::StatsMap Class Reference

Class modeling a mutable view on a map of statistics entries. More...

#include <stats.hh>

Inheritance diagram for Clingo::StatsMap:
Clingo::ConstStatsMap

Public Types

using key_type = std::string_view
 The key type of the map, which is a string view.
 
using mapped_type = Stats
 The mapped type of the map, which is a mutable stats entry.
 
using value_type = std::pair< key_type, mapped_type >
 The value type of the map, which is a pair of key and mapped type.
 
using size_type = std::size_t
 The size type of the map.
 
using difference_type = std::ptrdiff_t
 The difference type of the map.
 
using reference = value_type
 The reference type of the map, which corresponds to the value type.
 
using pointer = Detail::ArrowProxy< value_type >
 The pointer type of the map, which is a proxy to the value type.
 
using iterator = Detail::RandomAccessIterator< StatsMap >
 The iterator type, which is a random access iterator over value types.
 
- Public Types inherited from Clingo::ConstStatsMap
using key_type = std::string_view
 The key type of the map, which is a string view.
 
using mapped_type = ConstStats
 The mapped type of the map, which is an immutable stats entry.
 
using value_type = std::pair< key_type, mapped_type >
 The value type of the map, which is a pair of key and mapped type.
 
using size_type = std::size_t
 The size type of the map.
 
using difference_type = std::ptrdiff_t
 The difference type of the map.
 
using reference = value_type
 The reference type of the map, which is a pair of key and mapped type.
 
using pointer = Detail::ArrowProxy< value_type >
 The pointer type of the map, which is a proxy to the value type.
 
using iterator = Detail::RandomAccessIterator< ConstStatsMap >
 The iterator type, which is a random access iterator over value types.
 

Public Member Functions

 StatsMap (clingo_stats_t *stats, uint64_t key)
 Construct a statistics map from a pointer to the C API and a key.
 
auto at (size_t index) const -> value_type
 Get the name entry pair at the given index.
 
auto operator[] (std::string_view name) const -> Stats
 Get a statistics entry with the given name if the entry is a map.
 
auto get (std::string_view name) const -> Stats
 Get a statistics entry with the given name if the entry is a map.
 
auto insert (std::string_view name, StatsType type) const -> Stats
 Insert a statistics entry with the given name and type into the map.
 
auto begin () const -> iterator
 Get an iterator to the beginning of the map.
 
auto end () const -> iterator
 Get an iterator to the end of the map.
 
- Public Member Functions inherited from Clingo::ConstStatsMap
 ConstStatsMap (clingo_stats_t const *stats, uint64_t key)
 Construct a statistics map from a pointer to the C API and a key.
 
auto size () const -> size_t
 Get the size of the map.
 
auto at (size_t index) const -> value_type
 Get the name entry pair at the given index.
 
auto operator[] (std::string_view name) const -> ConstStats
 Get a statistics entry with the given name if the entry is a map.
 
auto get (std::string_view name) const -> ConstStats
 Get a statistics entry with the given name if the entry is a map.
 
auto contains (std::string_view name) const -> bool
 Check if the map contains a subkey with the given name.
 
auto begin () const -> iterator
 Get an iterator to the beginning of the map.
 
auto end () const -> iterator
 Get an iterator to the end of the map.
 

Detailed Description

Class modeling a mutable view on a map of statistics entries.

Constructor & Destructor Documentation

◆ StatsMap()

Clingo::StatsMap::StatsMap ( clingo_stats_t stats,
uint64_t  key 
)
inlineexplicit

Construct a statistics map from a pointer to the C API and a key.

Parameters
statsthe statistics entry to construct the map from
keythe key of the statistics entry

Member Function Documentation

◆ at()

auto Clingo::StatsMap::at ( size_t  index) const -> value_type
inline

Get the name entry pair at the given index.

Parameters
indexthe index of the entry to get
Returns
the name entry pair at the given index

◆ begin()

auto Clingo::StatsMap::begin ( ) const -> iterator
inline

Get an iterator to the beginning of the map.

Returns
an iterator to the beginning of the map

◆ end()

auto Clingo::StatsMap::end ( ) const -> iterator
inline

Get an iterator to the end of the map.

Returns
an iterator to the end of the map

◆ get()

auto Clingo::StatsMap::get ( std::string_view  name) const -> Stats
inline

Get a statistics entry with the given name if the entry is a map.

Parameters
namethe name of the statistics entry to get
Returns
a statistics entry with the given name

◆ insert()

auto Clingo::StatsMap::insert ( std::string_view  name,
StatsType  type 
) const -> Stats
inline

Insert a statistics entry with the given name and type into the map.

If the map already contains an entry with the given name, the existing entry is returned.

New entries have their default values; empty for arrays and lists, zero for numbers.

Parameters
namethe name of the statistics entry to insert
typethe type of the statistics entry to insert
Returns
a statistics entry with the given name and type

◆ operator[]()

auto Clingo::StatsMap::operator[] ( std::string_view  name) const -> Stats
inline

Get a statistics entry with the given name if the entry is a map.

Parameters
namethe name of the statistics entry to get
Returns
a statistics entry with the given name

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