klee
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 KLEE_IMMUTABLESET_H
11#define KLEE_IMMUTABLESET_H
12
13#include <functional>
14
15#include "ImmutableTree.h"
16
17namespace 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> >
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:
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 /* KLEE_IMMUTABLESET_H */
ImmutableTree< T, T, _Identity< T >, CMP > Tree
Definition: ImmutableSet.h:30
iterator lower_bound(const key_type &key) const
Definition: ImmutableSet.h:89
ImmutableSet popMin(const value_type &valueOut) const
Definition: ImmutableSet.h:73
const value_type & max() const
Definition: ImmutableSet.h:57
iterator begin() const
Definition: ImmutableSet.h:80
iterator find(const key_type &key) const
Definition: ImmutableSet.h:86
static size_t getAllocated()
Definition: ImmutableSet.h:96
ImmutableSet(const Tree &b)
Definition: ImmutableSet.h:36
iterator end() const
Definition: ImmutableSet.h:83
ImmutableSet & operator=(const ImmutableSet &b)
Definition: ImmutableSet.h:43
ImmutableSet insert(const value_type &value) const
Definition: ImmutableSet.h:64
ImmutableSet(const ImmutableSet &b)
Definition: ImmutableSet.h:40
size_t count(const key_type &key) const
Definition: ImmutableSet.h:48
Tree::iterator iterator
Definition: ImmutableSet.h:31
ImmutableSet remove(const key_type &key) const
Definition: ImmutableSet.h:70
ImmutableSet replace(const value_type &value) const
Definition: ImmutableSet.h:67
const value_type & min() const
Definition: ImmutableSet.h:54
iterator upper_bound(const key_type &key) const
Definition: ImmutableSet.h:92
ImmutableSet popMax(const value_type &valueOut) const
Definition: ImmutableSet.h:76
const value_type * lookup(const key_type &key) const
Definition: ImmutableSet.h:51
bool empty() const
Definition: ImmutableSet.h:45
ImmutableTree popMin(value_type &valueOut) const
iterator end() const
const value_type & max() const
ImmutableTree remove(const key_type &key) const
const value_type * lookup(const key_type &key) const
bool empty() const
iterator find(const key_type &key) const
ImmutableTree popMax(value_type &valueOut) const
size_t count(const key_type &key) const
size_t size() const
ImmutableTree insert(const value_type &value) const
ImmutableTree replace(const value_type &value) const
iterator lower_bound(const key_type &key) const
static size_t allocated
Definition: ImmutableTree.h:20
iterator begin() const
iterator upper_bound(const key_type &key) const
const value_type & min() const
Definition: main.cpp:291
const T & operator()(const T &a) const
Definition: ImmutableSet.h:21
T & operator()(T &a) const
Definition: ImmutableSet.h:20