DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
A Class for Efficient Key Lookup in C++ - Symbol(C++)

Symbol tables

A symbol table is a data structure which supports the following operations:

   enter(s, i): enter information i for symbol s into the table.
   lookup(s): return the last entered information i for s.
   If s is not in the table, return an error.

Typical symbol tables will support additional operations, but these are the fundamental ones. Here is a typical declaration for a symbol table in C++:

       class Info { ... };
       class Symbol_table {
       public:
           void enter(const char* s, Info* i);
           Info* lookup(const char* s);
           // ...
       };

The set of information for a symbol is modeled by a separate class Info (actually, a pointer to an instance of such a class). The symbols themselves are modeled by character strings. Although this representation of a symbol table is quite common, it is also inefficient, for reasons that will shortly become apparent.


Next topic: Remembering the hash
Previous topic: A Class for Efficient Key Lookup in C++ - Symbol(C++)

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005