klee
ImmutableMap.h
Go to the documentation of this file.
1//===-- ImmutableMap.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_IMMUTABLEMAP_H
11#define KLEE_IMMUTABLEMAP_H
12
13#include <functional>
14
15#include "ImmutableTree.h"
16
17namespace klee {
18 template<class V, class D>
19 struct _Select1st {
20 D &operator()(V &a) const { return a.first; }
21 const D &operator()(const V &a) const { return a.first; }
22 };
23
24 template<class K, class D, class CMP=std::less<K> >
26 public:
27 typedef K key_type;
28 typedef std::pair<K,D> value_type;
29
31 typedef typename Tree::iterator iterator;
32
33 private:
35
36 ImmutableMap(const Tree &b): elts(b) {}
37
38 public:
42
43 ImmutableMap &operator=(const ImmutableMap &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 *lookup_previous(const key_type &key) const {
55 return elts.lookup_previous(key);
56 }
57 const value_type &min() const {
58 return elts.min();
59 }
60 const value_type &max() const {
61 return elts.max();
62 }
63 size_t size() const {
64 return elts.size();
65 }
66
67 ImmutableMap insert(const value_type &value) const {
68 return elts.insert(value);
69 }
70 ImmutableMap replace(const value_type &value) const {
71 return elts.replace(value);
72 }
73 ImmutableMap remove(const key_type &key) const {
74 return elts.remove(key);
75 }
76 ImmutableMap popMin(const value_type &valueOut) const {
77 return elts.popMin(valueOut);
78 }
79 ImmutableMap popMax(const value_type &valueOut) const {
80 return elts.popMax(valueOut);
81 }
82
83 iterator begin() const {
84 return elts.begin();
85 }
86 iterator end() const {
87 return elts.end();
88 }
89 iterator find(const key_type &key) const {
90 return elts.find(key);
91 }
92 iterator lower_bound(const key_type &key) const {
93 return elts.lower_bound(key);
94 }
95 iterator upper_bound(const key_type &key) const {
96 return elts.upper_bound(key);
97 }
98
99 static size_t getAllocated() { return Tree::allocated; }
100 };
101
102}
103
104#endif /* KLEE_IMMUTABLEMAP_H */
ImmutableMap popMax(const value_type &valueOut) const
Definition: ImmutableMap.h:79
const value_type & max() const
Definition: ImmutableMap.h:60
iterator begin() const
Definition: ImmutableMap.h:83
iterator find(const key_type &key) const
Definition: ImmutableMap.h:89
iterator lower_bound(const key_type &key) const
Definition: ImmutableMap.h:92
const value_type * lookup(const key_type &key) const
Definition: ImmutableMap.h:51
ImmutableTree< K, value_type, _Select1st< value_type, key_type >, CMP > Tree
Definition: ImmutableMap.h:30
const value_type & min() const
Definition: ImmutableMap.h:57
size_t size() const
Definition: ImmutableMap.h:63
ImmutableMap replace(const value_type &value) const
Definition: ImmutableMap.h:70
size_t count(const key_type &key) const
Definition: ImmutableMap.h:48
ImmutableMap & operator=(const ImmutableMap &b)
Definition: ImmutableMap.h:43
ImmutableMap popMin(const value_type &valueOut) const
Definition: ImmutableMap.h:76
ImmutableMap remove(const key_type &key) const
Definition: ImmutableMap.h:73
bool empty() const
Definition: ImmutableMap.h:45
ImmutableMap(const Tree &b)
Definition: ImmutableMap.h:36
ImmutableMap(const ImmutableMap &b)
Definition: ImmutableMap.h:40
std::pair< K, D > value_type
Definition: ImmutableMap.h:28
ImmutableMap insert(const value_type &value) const
Definition: ImmutableMap.h:67
static size_t getAllocated()
Definition: ImmutableMap.h:99
const value_type * lookup_previous(const key_type &key) const
Definition: ImmutableMap.h:54
iterator upper_bound(const key_type &key) const
Definition: ImmutableMap.h:95
Tree::iterator iterator
Definition: ImmutableMap.h:31
iterator end() const
Definition: ImmutableMap.h:86
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
const value_type * lookup_previous(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
D & operator()(V &a) const
Definition: ImmutableMap.h:20
const D & operator()(const V &a) const
Definition: ImmutableMap.h:21