Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

ExprHashtable.h

Go to the documentation of this file.
00001 #ifndef EXPRHASHTABLE_H
00002 #define EXPRHASHTABLE_H
00003 
00004 #include "SundanceDefs.h"
00005 
00006 #include "ExprArray.h"
00007 #include <string>
00008 #include "TSFHashtable.h"
00009 #include "TSFQueue.h"
00010 
00011 
00012 namespace Sundance
00013 {
00014 
00015   using namespace TSF;
00016   using std::string;
00017 
00018   using std::ostream;
00019 
00020   class ExprHashtable
00021     {
00022     public:
00023       /**
00024        * Create an empty ExprHashtable
00025        */
00026       ExprHashtable(int capacity=101);
00027 
00028       bool containsKey(const string& key) const ;
00029 
00030       /**
00031        * Get the value indexed by key
00032        */
00033       const Expr& get(const string& key) const ;
00034       /**
00035        * Put a new (key, value) pair in the table.
00036        */
00037       void put(const string& key, const Expr& value);
00038 
00039       /**
00040        * Remove from the table the element given by key.
00041        */
00042       void remove(const string& key);
00043 
00044       /**
00045        * Get the number of elements in the table
00046        */
00047       int size() const ;
00048 
00049       void print(ostream& os) const ;
00050 
00051       /**
00052        * Write contents to a string
00053        */
00054       string toString() const ;
00055 
00056       /**
00057        * Test for equality with another hashtable
00058        */
00059       bool operator==(const ExprHashtable& other) const ;
00060 
00061       /**
00062        * Test relative ordering with another hashtable
00063        */
00064       bool operator<(const ExprHashtable& other) const ;
00065 
00066 
00067 
00068       /**
00069        * Get a sorted list of all unknown and variational functions
00070        */
00071       void getUnksAndVars(Expr& unk, Expr& var);
00072 
00073       /** return a list of key strings */
00074       TSFArray<string> getKeys() const ;
00075 
00076     private:
00077       TSFHashtable<string, int> indices_;
00078       TSFQueue<int> recycledIndices_;
00079       ExprArray exprs_;
00080     };
00081 
00082   inline ostream& operator<<(ostream& os, ExprHashtable& h)
00083     {
00084       h.print(os);
00085       return os;
00086     }
00087 
00088 
00089 }
00090 #endif

Contact:
Kevin Long (krlong@ca.sandia.gov)


Documentation generated by