00001 /* recordStack.h 00002 */ 00003 #ifndef SEARCH_RECORDSTACK_H 00004 #define SEARCH_RECORDSTACK_H 00005 00006 #include "osl/misc/fixedCapacityVector.h" 00007 #include <cassert> 00008 namespace osl 00009 { 00010 namespace search 00011 { 00012 class SimpleHashRecord; 00017 class RecordStack 00018 { 00019 static const int SEARCH_DEPTH_MAX = 128; 00020 FixedCapacityVector<SimpleHashRecord**, SEARCH_DEPTH_MAX> data; 00021 CArray<SimpleHashRecord*, SEARCH_DEPTH_MAX> backup; 00022 SimpleHashRecord *root_record; 00023 public: 00024 RecordStack(); 00025 RecordStack(const RecordStack&); 00026 void clear(); 00027 void push(SimpleHashRecord **r) { assert(r); data.push_back(r); } 00028 void pop() { assert(size() > 1); data.pop_back(); } 00029 00030 SimpleHashRecord** lastRecordPtr(unsigned int n=0) 00031 { 00032 assert(size() > n); 00033 return data[size()-1-n]; 00034 } 00035 SimpleHashRecord* lastRecord(unsigned int n=0) const 00036 { 00037 assert(size() > n); 00038 return *data[size()-1-n]; 00039 } 00040 00041 size_t size() const { return data.size(); } 00042 bool empty() const { return data.empty(); } 00043 bool hasLastRecord(unsigned int n=0) const 00044 { 00045 return size() > n; 00046 } 00047 00049 SimpleHashRecord** nextSeed() { return &backup[data.size()]; } 00050 void dump() const; 00051 }; 00052 } // namespace search 00053 } // namespace osl 00054 00055 00056 #endif /* SEARCH_RECORDSTACK_H */ 00057 // ;;; Local Variables: 00058 // ;;; mode:c++ 00059 // ;;; c-basic-offset:2 00060 // ;;; End: