/usr/include/cvc3/expr_map.h is in libcvc3-dev 2.4.1-5.1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | /*****************************************************************************/
/*!
* \file expr_map.h
*
* Author: Sergey Berezin
*
* Created: Dec 11 01:22:49 GMT 2002
*
* <hr>
*
* License to use, copy, modify, sell and/or distribute this software
* and its documentation for any purpose is hereby granted without
* royalty, subject to the terms and conditions defined in the \ref
* LICENSE file provided with this distribution.
*
* <hr>
*
*/
/*****************************************************************************/
// CLASS: ExprMap<Data>
//
// AUTHOR: Sergey Berezin, 12/10/2002
//
// Abstract:
//
// An abstract interface mapping Expr values to Data. The
// implementation is a hash table.
//
// Subclassing is NOT allowed; this would lose the iterators (can we
// fix it? Maybe not worth the trouble.)
//
// Functions follow the style of STL 'map' container.
//
// ExprMap<Data>() [Default constructor] Creates an empty map
// int count(Expr e) Counts the number of elements mapped from e.
// Normally, returns 0 or 1.
// Data& operator[](e) Returns Data associated with e. If e is not mapped,
// insert new Data() into ExprMap.
// Can be used to populate ExprMap as follows:
// ExprMap map;
// map[e1] = data1; map[e2] = data2; ...
// Caveat: Data must have a default constructor and be assignable.
// void erase(Expr e) Erase e->data mapping from ExprMap.
// void insert(Expr e, Data d) Insert e->d mapping.
// iterator begin() Return simple "input" iterators for ExprMap
// iterator end() (as defined in STL)
// size_t size() Return size of the map
// bool empty() Check for emptiness
///////////////////////////////////////////////////////////////////////////////
#ifndef _cvc3__expr_h_
#include "expr.h"
#endif
#ifndef _cvc3__expr_map_h_
#define _cvc3__expr_map_h_
#include "expr_hash.h"
namespace CVC3 {
template<class Data>
class ExprMap {
private:
typedef std::map<Expr, Data> ExprMapType;
// Private members
ExprMapType d_map;
public:
//////////////////////////////////////////////////////////////////////////
// Class: ExprMap::iterator
// Author: Sergey Berezin
// Created: Tue Dec 10 16:25:19 2002
// Description:
//////////////////////////////////////////////////////////////////////////
class const_iterator: public std::iterator<std::input_iterator_tag, std::pair<Expr,Data>,std::ptrdiff_t> {
friend class ExprMap;
private:
typename ExprMapType::const_iterator d_it;
// Private constructor
const_iterator(const typename ExprMapType::const_iterator& it)
: d_it(it) { }
public:
// Default constructor
const_iterator() { }
// (Dis)equality
bool operator==(const const_iterator& i) const { return d_it == i.d_it; }
bool operator!=(const const_iterator& i) const { return d_it != i.d_it; }
// Dereference operators.
const std::pair<const Expr,Data>& operator*() const { return *d_it; }
const std::pair<const Expr,Data>* operator->() const {
return d_it.operator->();
}
// Prefix increment
const_iterator& operator++() { ++d_it; return *this; }
// Postfix increment: requires a Proxy object to hold the
// intermediate value for dereferencing
class Proxy {
const std::pair<const Expr,Data>& d_pair;
public:
Proxy(const std::pair<Expr,Data>& pair) : d_pair(pair) { }
std::pair<const Expr,Data> operator*() { return d_pair; }
}; // end of class Proxy
// Actual postfix increment: returns Proxy with the old value.
// Now, an expression like *i++ will return the current *i, and
// then advance the iterator. However, don't try to use Proxy for
// anything else.
Proxy operator++(int) {
Proxy tmp(*(*this));
++(*this);
return tmp;
}
// Prefix decrement
const_iterator& operator--() { --d_it; return *this; }
}; // end of class const_iterator
class iterator: public std::iterator<std::input_iterator_tag, std::pair<Expr,Data>,std::ptrdiff_t> {
friend class ExprMap;
private:
typename ExprMapType::iterator d_it;
// Private constructor
iterator(const typename ExprMapType::iterator& it)
: d_it(it) { }
public:
// Default constructor
iterator() { }
// (Dis)equality
bool operator==(const iterator& i) const { return d_it == i.d_it; }
bool operator!=(const iterator& i) const { return d_it != i.d_it; }
// Dereference operators.
std::pair<const Expr,Data>& operator*() const { return *d_it; }
std::pair<const Expr,Data>* operator->() const {
return d_it.operator->();
}
// Prefix increment
iterator& operator++() { ++d_it; return *this; }
// Postfix increment: requires a Proxy object to hold the
// intermediate value for dereferencing
class Proxy {
std::pair<const Expr,Data>& d_pair;
public:
Proxy(std::pair<const Expr,Data>& pair) : d_pair(pair) { }
std::pair<const Expr,Data> operator*() { return d_pair; }
}; // end of class Proxy
// Actual postfix increment: returns Proxy with the old value.
// Now, an expression like *i++ will return the current *i, and
// then advance the iterator. However, don't try to use Proxy for
// anything else.
Proxy operator++(int) {
Proxy tmp(*(*this));
++(*this);
return tmp;
}
// Prefix decrement
iterator& operator--() { --d_it; return *this; }
}; // end of class iterator
//////////////////////////////////////////////////////////////////////////
// Public methods
//////////////////////////////////////////////////////////////////////////
// Default constructor
ExprMap() { }
// Copy constructor
ExprMap(const ExprMap& map): d_map(map.d_map) { }
// Other methods
bool empty() const { return d_map.empty(); }
size_t size() const { return d_map.size(); }
size_t count(const Expr& e) const { return d_map.count(e); }
Data& operator[](const Expr& e) { return d_map[e]; }
void clear() { d_map.clear(); }
void insert(const Expr& e, const Data& d) { d_map[e] = d; }
void erase(const Expr& e) { d_map.erase(e); }
template<class InputIterator>
void insert(InputIterator l, InputIterator r) { d_map.insert(l,r); }
template<class InputIterator>
void erase(InputIterator l, InputIterator r) {
for(; l!=r; ++l) {
d_map.erase((*l).first);
}
}
iterator begin() { return iterator(d_map.begin()); }
iterator end() { return iterator(d_map.end()); }
const_iterator begin() const { return const_iterator(d_map.begin()); }
const_iterator end() const { return const_iterator(d_map.end()); }
iterator find(const Expr& e) { return iterator(d_map.find(e)); }
const_iterator find(const Expr& e) const { return const_iterator(d_map.find(e)); }
friend bool operator==(const ExprMap& m1, const ExprMap& m2) {
return m1.d_map == m2.d_map;
}
friend bool operator!=(const ExprMap& m1, const ExprMap& m2) {
return !(m1 == m2);
}
}; // end of class ExprMap
template<class Data>
class ExprHashMap {
private:
typedef std::hash_map<Expr, Data> ExprHashMapType;
// Private members
ExprHashMapType d_map;
public:
class const_iterator: public std::iterator<std::input_iterator_tag, std::pair<Expr,Data>,std::ptrdiff_t> {
friend class ExprHashMap;
private:
typename ExprHashMapType::const_iterator d_it;
// Private constructor
const_iterator(const typename ExprHashMapType::const_iterator& it)
: d_it(it) { }
public:
// Default constructor
const_iterator() { }
// (Dis)equality
bool operator==(const const_iterator& i) const { return d_it == i.d_it; }
bool operator!=(const const_iterator& i) const { return d_it != i.d_it; }
// Dereference operators.
const std::pair<const Expr,Data>& operator*() const { return *d_it; }
const std::pair<const Expr,Data>* operator->() const {
return d_it.operator->();
}
// Prefix increment
const_iterator& operator++() { ++d_it; return *this; }
// Postfix increment: requires a Proxy object to hold the
// intermediate value for dereferencing
class Proxy {
const std::pair<const Expr,Data>& d_pair;
public:
Proxy(const std::pair<Expr,Data>& pair) : d_pair(pair) { }
std::pair<const Expr,Data> operator*() { return d_pair; }
}; // end of class Proxy
// Actual postfix increment: returns Proxy with the old value.
// Now, an expression like *i++ will return the current *i, and
// then advance the iterator. However, don't try to use Proxy for
// anything else.
Proxy operator++(int) {
Proxy tmp(*(*this));
++(*this);
return tmp;
}
}; // end of class const_iterator
class iterator: public std::iterator<std::input_iterator_tag, std::pair<Expr,Data>,std::ptrdiff_t> {
friend class ExprHashMap;
private:
typename ExprHashMapType::iterator d_it;
// Private constructor
iterator(const typename ExprHashMapType::iterator& it)
: d_it(it) { }
public:
// Default constructor
iterator() { }
// (Dis)equality
bool operator==(const iterator& i) const { return d_it == i.d_it; }
bool operator!=(const iterator& i) const { return d_it != i.d_it; }
// Dereference operators.
std::pair<const Expr,Data>& operator*() const { return *d_it; }
std::pair<const Expr,Data>* operator->() const {
return d_it.operator->();
}
// Prefix increment
iterator& operator++() { ++d_it; return *this; }
// Postfix increment: requires a Proxy object to hold the
// intermediate value for dereferencing
class Proxy {
std::pair<const Expr,Data>& d_pair;
public:
Proxy(std::pair<const Expr,Data>& pair) : d_pair(pair) { }
std::pair<const Expr,Data> operator*() { return d_pair; }
}; // end of class Proxy
// Actual postfix increment: returns Proxy with the old value.
// Now, an expression like *i++ will return the current *i, and
// then advance the iterator. However, don't try to use Proxy for
// anything else.
Proxy operator++(int) {
Proxy tmp(*(*this));
++(*this);
return tmp;
}
}; // end of class iterator
//////////////////////////////////////////////////////////////////////////
// Public methods
//////////////////////////////////////////////////////////////////////////
//! Default constructor
ExprHashMap() { }
//! Constructor specifying the initial number of buckets
ExprHashMap(size_t n): d_map(n) { }
// Copy constructor
ExprHashMap(const ExprHashMap& map): d_map(map.d_map) { }
// Other methods
bool empty() const { return d_map.empty(); }
size_t size() const { return d_map.size(); }
size_t count(const Expr& e) const { return d_map.count(e); }
Data& operator[](const Expr& e) { return d_map[e]; }
void clear() { d_map.clear(); }
void insert(const Expr& e, const Data& d) { d_map[e] = d; }
void erase(const Expr& e) { d_map.erase(e); }
template<class InputIterator>
void insert(InputIterator l, InputIterator r) { d_map.insert(l,r); }
template<class InputIterator>
void erase(InputIterator l, InputIterator r) {
for(; l!=r; ++l) {
d_map.erase((*l).first);
}
}
iterator begin() { return iterator(d_map.begin()); }
iterator end() { return iterator(d_map.end()); }
const_iterator begin() const { return const_iterator(d_map.begin()); }
const_iterator end() const { return const_iterator(d_map.end()); }
iterator find(const Expr& e) { return iterator(d_map.find(e)); }
const_iterator find(const Expr& e) const { return const_iterator(d_map.find(e)); }
// These aren't implemented
// friend bool operator==(const ExprHashMap& m1, const ExprHashMap& m2) {
// return m1.d_map == m2.d_map;
// }
// friend bool operator!=(const ExprHashMap& m1, const ExprHashMap& m2) {
// return !(m1 == m2);
// }
}; // end of class ExprHashMap
} // end of namespace CVC3
#endif
|