symbol_table.h

Go to the documentation of this file.
00001 #ifndef SYMBOL_TABLE_CLASS
00002 #define SYMBOL_TABLE_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : symbol_table                                                      *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1991-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "data_structure_dll.h"
00019 
00020 #include <basis/istring.h>
00021 
00022 // forward.
00023 class string_set;
00024 template <class contents> class internal_symbol_indexer;
00025 template <class contents> class internal_symbol_info;
00026 template <class contents> class internal_symbol_list;
00027 
00029 
00030 template <class contents>
00031 class symbol_table
00032 {
00033 public:
00035 
00038   symbol_table(int max_bits = 7);
00039 
00040   symbol_table(const symbol_table<contents> &to_copy);
00041 
00042   ~symbol_table();
00043 
00044   int symbols() const;
00046 
00047   int max_bits() const;  
00048 
00049   void rehash(int max_bits);  
00050 
00051   void hash_appropriately(int max_per_bucket);
00053 
00060   symbol_table &operator =(const symbol_table<contents> &to_copy);
00061 
00062   outcome add(const istring &name, const contents &storage);
00064 
00068   const istring &name(int index) const;
00070 
00072   void names(string_set &to_fill) const;
00074 
00075   contents &operator [] (int index);
00077   const contents &operator [] (int index) const;
00079 
00080   inline const contents &get(int index) const { return operator[](index); }
00082   inline contents &use(int index) { return operator[](index); }
00084 
00085   contents *find(const istring &name) const;
00087 
00088   contents *find(const istring &name,
00089           string_comparator_function *comparator) const;
00091 
00097   int dep_find(const istring &name) const;
00099 
00102 
00103 
00106   outcome retrieve(int index, istring &symbol_name, contents &contains) const;
00107 
00108   outcome whack(const istring &name);
00110 
00112   outcome zap_index(int index);
00114 
00115   void reset();  //<! removes all symbols from the table.
00116 
00117 private:
00118   internal_symbol_list<contents> *_symbol_list;  
00119   internal_symbol_indexer<contents> *_tracker;  
00120 
00121   internal_symbol_info<contents> *get_index(int index) const;
00123 };
00124 
00126 
00127 template <class contents>
00128 bool symbol_table_compare(const symbol_table<contents> &a,
00129     const symbol_table<contents> &b);
00131 
00132 #endif
00133 

Generated on Fri Nov 21 04:29:42 2008 for HOOPLE Libraries by  doxygen 1.5.1