00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef HxQCollection_h_
00010 #define HxQCollection_h_
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <set>
00025 #include <queue>
00026 #include <stack>
00027
00028 template <class T>
00029 class Qset {
00030 private:
00031 typedef std::set<T> Container;
00032 Container container;
00033 Qset(const Qset &);
00034 Qset & operator = (const Qset &);
00035 public:
00036
00037 typedef Container::iterator iterator;
00038
00039 Qset() {}
00040 ~Qset() {}
00041 bool empty() const { return container.empty(); }
00042 Container::size_type size() const { return container.size(); }
00043 void clear() { container.clear(); }
00044 void push(const T &val) { container.insert(val); }
00045 void erase(iterator iter) { container.erase(iter); }
00046 iterator after_upper_bound(const T &val) {
00047 iterator iter=container.upper_bound(val);
00048 if (iter!=container.end()) iter++;
00049 return iter;
00050 }
00051 iterator lower_bound(const T &val) { return container.lower_bound(val); }
00052 void pop() { container.erase(container.begin()); }
00053
00054 typedef Container::reference reference;
00055 reference top() { return *container.begin(); }
00056 };
00057
00058 class Int {
00059 private:
00060 int val;
00061 public:
00062 Int() : val(0) {}
00063 void operator ++ (int) { val++; }
00064 operator int() const { return val; }
00065 };
00066
00067 class Bugs {
00068 private:
00069 std::map<int,Int> m;
00070
00071 Bugs(const Bugs &);
00072 Bugs & operator = (const Bugs &);
00073 std::string fn;
00074 public:
00075 Bugs(const char *cc=__FILE__) : fn(cc) {}
00076 void plusplus(int i) { m[i]++; }
00077 ~Bugs() {
00078 if (!m.empty()) { std::cout << m.size() << "Bugs founds in file " << fn << std::endl; }
00079 for (std::map<int,Int>::const_iterator iter=m.begin(); iter!=m.end(); iter++) {
00080 std::cout << "error in line " << iter->first <<", #=" << iter->second << std::endl;
00081 }
00082 }
00083 };
00084
00085 template <class T>
00086 class Qpriority_queue {
00087 private:
00088 typedef std::priority_queue<T> Container;
00089 Container container;
00090 Qpriority_queue(const Qpriority_queue &);
00091 Qpriority_queue & operator = (const Qpriority_queue &);
00092 Bugs bugs;
00093 public:
00094 Qpriority_queue() {}
00095 ~Qpriority_queue() {}
00096 bool empty() const { return container.empty(); }
00097 Container::size_type size() const { return container.size(); }
00098 void push(const T &val) { container.push(val); }
00099 void pop() { container.pop(); }
00100 T & top() { return container.top(); }
00101
00102 typedef T *iterator;
00103 void clear() { bugs.plusplus(__LINE__); }
00104 void erase(iterator iter) { bugs.plusplus(__LINE__); }
00105 iterator lower_bound(const T &val) { bugs.plusplus(__LINE__); return NULL; }
00106 iterator after_upper_bound(const T &val) { bugs.plusplus(__LINE__); return NULL; }
00107 };
00108
00109
00110
00111
00112
00113 template<class Ty, class C>
00114 class msvcqueue : public std::queue<Ty, C> {
00115 public:
00116 #ifdef WIN32
00117 value_type& top() { return (c.front()); }
00118 const value_type& top() const { return (c.front()); }
00119 #else
00120 reference top() { return (c.front()); }
00121 const_reference top() const { return (c.front()); }
00122 #endif
00123
00124 };
00125
00126
00127 template <class T>
00128 class Qqueue {
00129 private:
00130
00131
00132 typedef msvcqueue<T, std::deque<T> > Container;
00133 Container container;
00134 Qqueue(const Qqueue &);
00135 Qqueue & operator = (const Qqueue &);
00136 Bugs bugs;
00137 public:
00138 Qqueue() {}
00139 ~Qqueue() {}
00140 bool empty() const { return container.empty(); }
00141 Container::size_type size() const { return container.size(); }
00142 void push(const T &val) { container.push(val); }
00143 void pop() { container.pop(); }
00144 T & top() { return container.top(); }
00145
00146 typedef T *iterator;
00147 void clear() { bugs.plusplus(__LINE__); }
00148
00149 void erase(iterator iter) { bugs.plusplus(__LINE__); }
00150 iterator lower_bound(const T &val) { bugs.plusplus(__LINE__); return NULL; }
00151 iterator after_upper_bound(const T &val) { bugs.plusplus(__LINE__); return NULL; }
00152 };
00153
00154
00155
00156
00157 template<class Ty, class C>
00158 class msvcstack : public std::stack<Ty, C> {
00159 public:
00160
00161 };
00162
00163
00164 template <class T>
00165 class Qstack {
00166 private:
00167
00168
00169 typedef msvcstack<T, std::vector<T> > Container;
00170 Container container;
00171 Qstack(const Qstack &);
00172 Qstack & operator = (const Qstack &);
00173 Bugs bugs;
00174 public:
00175 Qstack() {}
00176 ~Qstack() {}
00177 bool empty() const { return container.empty(); }
00178 Container::size_type size() const { return container.size(); }
00179 void push(const T &val) { container.push(val); }
00180 void pop() { container.pop(); }
00181 T & top() { return container.top(); }
00182
00183 typedef T* iterator;
00184 void clear() { bugs.plusplus(__LINE__); }
00185
00186 void erase(iterator iter) { bugs.plusplus(__LINE__); }
00187 iterator lower_bound(const T &val) { bugs.plusplus(__LINE__); return NULL; }
00188 iterator after_upper_bound(const T &val) { bugs.plusplus(__LINE__); return NULL; }
00189 };
00190
00191
00192
00193 #endif
00194