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
00025
00026 ExprHashtable(int capacity=101);
00027
00028 bool containsKey(const string& key) const ;
00029
00030
00031
00032
00033 const Expr& get(const string& key) const ;
00034
00035
00036
00037 void put(const string& key, const Expr& value);
00038
00039
00040
00041
00042 void remove(const string& key);
00043
00044
00045
00046
00047 int size() const ;
00048
00049 void print(ostream& os) const ;
00050
00051
00052
00053
00054 string toString() const ;
00055
00056
00057
00058
00059 bool operator==(const ExprHashtable& other) const ;
00060
00061
00062
00063
00064 bool operator<(const ExprHashtable& other) const ;
00065
00066
00067
00068
00069
00070
00071 void getUnksAndVars(Expr& unk, Expr& var);
00072
00073
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