klee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ImmutableSet.h
Go to the documentation of this file.
1 //===-- ImmutableSet.h ------------------------------------------*- C++ -*-===//
2 //
3 // The KLEE Symbolic Virtual Machine
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef __UTIL_IMMUTABLESET_H__
11 #define __UTIL_IMMUTABLESET_H__
12 
13 #include <functional>
14 
15 #include "ImmutableTree.h"
16 
17 namespace klee {
18  template<class T>
19  struct _Identity {
20  T &operator()(T &a) const { return a; }
21  const T &operator()(const T &a) const { return a; }
22  };
23 
24  template<class T, class CMP=std::less<T> >
25  class ImmutableSet {
26  public:
27  typedef T key_type;
28  typedef T value_type;
29 
31  typedef typename Tree::iterator iterator;
32 
33  private:
35 
36  ImmutableSet(const Tree &b): elts(b) {}
37 
38  public:
40  ImmutableSet(const ImmutableSet &b) : elts(b.elts) {}
42 
43  ImmutableSet &operator=(const ImmutableSet &b) { elts = b.elts; return *this; }
44 
45  bool empty() const {
46  return elts.empty();
47  }
48  size_t count(const key_type &key) const {
49  return elts.count(key);
50  }
51  const value_type *lookup(const key_type &key) const {
52  return elts.lookup(key);
53  }
54  const value_type &min() const {
55  return elts.min();
56  }
57  const value_type &max() const {
58  return elts.max();
59  }
60  size_t size() {
61  return elts.size();
62  }
63 
64  ImmutableSet insert(const value_type &value) const {
65  return elts.insert(value);
66  }
67  ImmutableSet replace(const value_type &value) const {
68  return elts.replace(value);
69  }
70  ImmutableSet remove(const key_type &key) const {
71  return elts.remove(key);
72  }
73  ImmutableSet popMin(const value_type &valueOut) const {
74  return elts.popMin(valueOut);
75  }
76  ImmutableSet popMax(const value_type &valueOut) const {
77  return elts.popMax(valueOut);
78  }
79 
80  iterator begin() const {
81  return elts.begin();
82  }
83  iterator end() const {
84  return elts.end();
85  }
86  iterator find(const key_type &key) const {
87  return elts.find(key);
88  }
89  iterator lower_bound(const key_type &key) const {
90  return elts.lower_bound(key);
91  }
92  iterator upper_bound(const key_type &key) const {
93  return elts.upper_bound(key);
94  }
95 
96  static size_t getAllocated() { return Tree::allocated; }
97  };
98 
99 }
100 
101 #endif
const T & operator()(const T &a) const
Definition: ImmutableSet.h:21
ImmutableSet popMin(const value_type &valueOut) const
Definition: ImmutableSet.h:73
iterator end() const
ImmutableTree remove(const key_type &key) const
iterator begin() const
ImmutableTree insert(const value_type &value) const
ImmutableSet replace(const value_type &value) const
Definition: ImmutableSet.h:67
iterator lower_bound(const key_type &key) const
ImmutableSet(const Tree &b)
Definition: ImmutableSet.h:36
ImmutableTree popMin(value_type &valueOut) const
const value_type * lookup(const key_type &key) const
Definition: ImmutableSet.h:51
ImmutableSet(const ImmutableSet &b)
Definition: ImmutableSet.h:40
iterator upper_bound(const key_type &key) const
Definition: ImmutableSet.h:92
iterator find(const key_type &key) const
Definition: ImmutableSet.h:86
const value_type & min() const
Definition: ImmutableSet.h:54
const value_type * lookup(const key_type &key) const
ImmutableTree replace(const value_type &value) const
size_t count(const key_type &key) const
Definition: ImmutableSet.h:48
const value_type & max() const
ImmutableTree popMax(value_type &valueOut) const
size_t size() const
iterator find(const key_type &key) const
iterator end() const
Definition: ImmutableSet.h:83
ImmutableSet popMax(const value_type &valueOut) const
Definition: ImmutableSet.h:76
T & operator()(T &a) const
Definition: ImmutableSet.h:20
Tree::iterator iterator
Definition: ImmutableSet.h:31
ImmutableTree< T, T, _Identity< T >, CMP > Tree
Definition: ImmutableSet.h:30
const value_type & max() const
Definition: ImmutableSet.h:57
bool empty() const
ImmutableSet & operator=(const ImmutableSet &b)
Definition: ImmutableSet.h:43
static size_t getAllocated()
Definition: ImmutableSet.h:96
iterator lower_bound(const key_type &key) const
Definition: ImmutableSet.h:89
const value_type & min() const
iterator upper_bound(const key_type &key) const
iterator begin() const
Definition: ImmutableSet.h:80
size_t count(const key_type &key) const
bool empty() const
Definition: ImmutableSet.h:45
ImmutableSet insert(const value_type &value) const
Definition: ImmutableSet.h:64