Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
Clasp::SymbolTable Class Reference

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

#include <literal.h>

List of all members.

Classes

struct  LessKey
struct  String
struct  symbol_type

Public Types

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

Public Member Functions

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

Private Member Functions

const char * dupName (const char *n) const
void freeName (const char *n) const
SymbolTableoperator= (const SymbolTable &)
 SymbolTable (const SymbolTable &)
bool unique () const

Private Attributes

uint32 end_
map_type::size_type lastSort_
map_type::size_type lastStart_
map_type map_
MapType type_

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

Definition at line 249 of file literal.h.


Member Typedef Documentation

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

Definition at line 269 of file literal.h.

Definition at line 260 of file literal.h.

Definition at line 259 of file literal.h.

Definition at line 268 of file literal.h.

Definition at line 267 of file literal.h.


Member Enumeration Documentation

Enumerator:
map_direct 
map_indirect 

Definition at line 270 of file literal.h.


Constructor & Destructor Documentation

Creates an empty symbol table.

Definition at line 273 of file literal.h.

Definition at line 274 of file literal.h.


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.

Definition at line 335 of file literal.h.

Returns an iterator pointing to the beginning of this index.

Definition at line 294 of file literal.h.

void Clasp::SymbolTable::clear ( ) [inline]

Removes all symbols from this table.

Definition at line 316 of file literal.h.

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

Definition at line 275 of file literal.h.

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

Definition at line 296 of file literal.h.

const char* Clasp::SymbolTable::dupName ( const char *  n) const [inline, private]

Definition at line 357 of file literal.h.

Returns an iterator pointing behind the end of this index.

Definition at line 298 of file literal.h.

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.

Definition at line 345 of file literal.h.

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).

Definition at line 300 of file literal.h.

void Clasp::SymbolTable::freeName ( const char *  n) const [inline, private]

Definition at line 364 of file literal.h.

Definition at line 304 of file literal.h.

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

Returns the symbol with the given id.

Precondition:
find(id) != 0

Definition at line 311 of file literal.h.

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

Returns the number of symbols in this table.

Definition at line 292 of file literal.h.

void Clasp::SymbolTable::startInit ( ) [inline]

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

Definition at line 325 of file literal.h.

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.

Definition at line 290 of file literal.h.

bool Clasp::SymbolTable::unique ( ) const [inline, private]

Definition at line 365 of file literal.h.


Member Data Documentation

uint32 Clasp::SymbolTable::end_ [private]

Definition at line 379 of file literal.h.

map_type::size_type Clasp::SymbolTable::lastSort_ [private]

Definition at line 377 of file literal.h.

map_type::size_type Clasp::SymbolTable::lastStart_ [private]

Definition at line 378 of file literal.h.

Definition at line 376 of file literal.h.

Definition at line 380 of file literal.h.


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


clasp
Author(s): Benjamin Kaufmann
autogenerated on Thu Aug 27 2015 12:41:41