hashKeyStack.h
Go to the documentation of this file.
1 /* hashKeyStack.h
2  */
3 #ifndef HASH_HASHKEYSTACK_H
4 #define HASH_HASHKEYSTACK_H
5 #include "osl/hashKey.h"
6 #include <vector>
7 namespace osl
8 {
9  namespace hash
10  {
11  class HashKeyStack
12  {
13  typedef std::vector<HashKey> vector_t;
14  vector_t data;
15  public:
16  explicit HashKeyStack(size_t capacity=0);
17  ~HashKeyStack();
18 
19  void push(const HashKey&);
20  void pop() { assert(! data.empty()); data.pop_back(); }
21  void clear() { data.clear(); }
22 
23  const HashKey& top(size_t n=0) const
24  {
25  assert(n < size());
26  vector_t::const_reverse_iterator p=data.rbegin()+n;
27  return *p;
28  }
29  bool empty() const { return data.empty(); }
30  size_t size() const { return data.size(); }
31 
32  void dump() const;
33 
34  friend bool operator==(const HashKeyStack&, const HashKeyStack&);
35  };
36  } // namespace hash
37  using hash::HashKeyStack;
38 } // namespace osl
39 
40 #endif /* HASH_HASHKEYSTACK_H */
41 // ;;; Local Variables:
42 // ;;; mode:c++
43 // ;;; c-basic-offset:2
44 // ;;; End:
friend bool operator==(const HashKeyStack &, const HashKeyStack &)
Definition: hashKeyStack.cc:36
std::vector< HashKey > vector_t
Definition: hashKeyStack.h:13
const HashKey & top(size_t n=0) const
Definition: hashKeyStack.h:23
void push(const HashKey &)
Definition: hashKeyStack.cc:18
size_t size() const
Definition: hashKeyStack.h:30
HashKeyStack(size_t capacity=0)
Definition: hashKeyStack.cc:7