clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Classes | Public Types | Public Member Functions | List of all members
Clasp::SymbolTable Class Reference

Symbol table that maps external ids to internal literals. More...

#include <literal.h>

Collaboration diagram for Clasp::SymbolTable:
Collaboration graph

Classes

struct  symbol_type
 

Public Types

enum  MapType { map_direct, map_indirect }
 
typedef uint32 key_type
 
typedef String data_type
 
typedef std::pair< key_type,
symbol_type
value_type
 
typedef PodVector< value_type >
::type 
map_type
 
typedef map_type::const_iterator const_iterator
 

Public Member Functions

 SymbolTable ()
 Creates an empty symbol table. More...
 
 ~SymbolTable ()
 
void copyTo (SymbolTable &o)
 
MapType type () const
 Type of symbol mapping. More...
 
uint32 size () const
 Returns the number of symbols in this table. More...
 
const_iterator begin () const
 Returns an iterator pointing to the beginning of this index. More...
 
const_iterator curBegin () const
 Returns an iterator pointing to the first atom of the current incremental step. More...
 
const_iterator end () const
 Returns an iterator pointing behind the end of this index. More...
 
const symbol_typefind (key_type i) const
 Returns the symbol with id i or 0 if no such symbol exists (yet). More...
 
const_iterator lower_bound (const_iterator start, key_type i) const
 
const symbol_typeoperator[] (key_type id) const
 Returns the symbol with the given id. More...
 
void clear ()
 Removes all symbols from this table. More...
 
void startInit ()
 Prepares the symbol table so that new symbols can be added. More...
 
symbol_typeaddUnique (key_type id, const char *name)
 Adds the symbol with the given id to the symbol table. More...
 
void endInit (MapType type=map_indirect, Var end=varMax)
 Freezes the symbol table and prepares it so that lookup operations become valid. More...
 

Detailed Description

Symbol table that maps external ids to internal literals.

A symbol table can be populated incrementally, but each incremental step must be started with a call to startInit() and stopped with a call to endInit(). New symbols only become visible once endInit() was called.

The following invariants must hold but are not fully checked:

  1. Symbol ids are added at most once
  2. All Ids added in step I+1 are greater than those added in step I

Member Typedef Documentation

typedef map_type::const_iterator Clasp::SymbolTable::const_iterator

Member Enumeration Documentation

Enumerator
map_direct 
map_indirect 

Constructor & Destructor Documentation

Clasp::SymbolTable::SymbolTable ( )
inline

Creates an empty symbol table.

Clasp::SymbolTable::~SymbolTable ( )
inline

Here is the call graph for this function:

Member Function Documentation

symbol_type& Clasp::SymbolTable::addUnique ( key_type  id,
const char *  name 
)
inline

Adds the symbol with the given id to the symbol table.

Precondition
startInit() was called
the symbol table does not yet contain a symbol with the given id
Note
The new symbol only becomes visible once endInit() is called.

Here is the call graph for this function:

const_iterator Clasp::SymbolTable::begin ( ) const
inline

Returns an iterator pointing to the beginning of this index.

void Clasp::SymbolTable::clear ( )
inline

Removes all symbols from this table.

Here is the call graph for this function:

void Clasp::SymbolTable::copyTo ( SymbolTable o)
inline

Here is the call graph for this function:

const_iterator Clasp::SymbolTable::curBegin ( ) const
inline

Returns an iterator pointing to the first atom of the current incremental step.

const_iterator Clasp::SymbolTable::end ( ) const
inline

Returns an iterator pointing behind the end of this index.

void Clasp::SymbolTable::endInit ( MapType  type = map_indirect,
Var  end = varMax 
)
inline

Freezes the symbol table and prepares it so that lookup operations become valid.

Here is the call graph for this function:

const symbol_type* Clasp::SymbolTable::find ( key_type  i) const
inline

Returns the symbol with id i or 0 if no such symbol exists (yet).

Here is the call graph for this function:

const_iterator Clasp::SymbolTable::lower_bound ( const_iterator  start,
key_type  i 
) const
inline

Here is the call graph for this function:

const symbol_type& Clasp::SymbolTable::operator[] ( key_type  id) const
inline

Returns the symbol with the given id.

Precondition
find(id) != 0

Here is the call graph for this function:

uint32 Clasp::SymbolTable::size ( ) const
inline

Returns the number of symbols in this table.

Here is the call graph for this function:

void Clasp::SymbolTable::startInit ( )
inline

Prepares the symbol table so that new symbols can be added.

MapType Clasp::SymbolTable::type ( ) const
inline

Type of symbol mapping.

In a direct mapping, symbol ids directly correspond to solver variables. In an indirect mapping, symbol ids are independent of solver variables and are instead mapped to solver literals.


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