/usr/include/cvc3/hash_set.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 | /*****************************************************************************/
/*!
*\file hash_set.h
*\brief hash map implementation
*
* Author: Alexander Fuchs
*
* Created: Thu Oct 19 11:04:00 2006
*
* <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>
*/
/*****************************************************************************/
/*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
// this implementation is in essence a subset of the SGI implementation:
// http://www.sgi.com/tech/stl/stl_hash_set.h
#ifndef _cvc3__hash__hash_set_h_
#define _cvc3__hash__hash_set_h_
#include "hash_fun.h"
#include "hash_table.h"
namespace Hash {
// identity is an extension taken from the SGI
// implementation of the STL file functional:
// http://www.sgi.com/tech/stl/stl_function.h
template <class _Tp>
struct _Identity : public std::unary_function<_Tp,_Tp> {
const _Tp& operator()(const _Tp& __x) const { return __x; }
};
/*! hash set implementation based on the sgi interface:
http://www.sgi.com/tech/stl/hash_set.html
_Key: hash key type
_HashFcn: functional class providing a hash function: size_type (_Key)
_EqualKey: functional class providing a comparison function: bool(_Key, _Key)
returns true iff two keys are considered to be equal
*/
template <class _Key, class _HashFcn = hash<_Key>,
class _EqualKey = std::equal_to<_Key> >
class hash_set {
/// types
protected:
typedef hash_table<_Key, _Key, _HashFcn, _EqualKey, _Identity<_Key> > _hash_table;
public:
// typedefs as custom for other implementations
typedef typename _hash_table::size_type size_type;
typedef typename _hash_table::key_type key_type;
typedef typename _hash_table::value_type value_type;
typedef typename _hash_table::hasher hasher;
typedef typename _hash_table::key_equal key_equal;
public:
// iterators
typedef typename _hash_table::iterator iterator;
typedef typename _hash_table::const_iterator const_iterator;
/// variables
protected:
// the hash table
_hash_table d_table;
/// methods
public:
/// constructors
// default size is 16 buckets
hash_set() :
d_table()
{ };
// specifiy initial number of buckets - must be positive
hash_set(size_type initial_capacity) :
d_table(initial_capacity)
{ };
// specifiy initial number of buckets and hash function
hash_set(size_type initial_capacity, const _HashFcn& hash) :
d_table(initial_capacity, hash)
{ };
// specifiy initial number of buckets, hash and equal function
hash_set(size_type initial_capacity,
const _HashFcn& hash, const _EqualKey& equal) :
d_table(initial_capacity, hash, equal)
{ };
// copy hash map.
hash_set(const hash_set& other) :
d_table(other.d_table)
{ };
// assign hash map
hash_set& operator=(const hash_set& other) {
if (this != &other) {
d_table = other.d_table;
}
return *this;
}
void swap(hash_set& other) {
d_table.swap(other.d_table);
}
// removes all entries, number of buckets is not reduced.
void clear() {
d_table.clear();
};
/// operations
// returns end iterator if key was not bound
iterator find(const key_type& key) {
return d_table.find(key);
}
// const version of find
const_iterator find(const key_type& key) const {
return d_table.find(key);
}
// adds the mapping from key to data, if key is still unbound
// otherwise returns false
std::pair<iterator, bool> insert(const value_type& entry) {
return d_table.insert(entry);
}
// removes binding of key
// returns number of keys removed,
// i.e. 1 if key was bound, 0 if key was not bound.
size_type erase(const key_type& key) {
return d_table.erase(key);
}
/// status
// is the key bound?
bool contains(const key_type& key) const {
return d_table.contains(key);
}
// returns the number of times a key is bound,
// i.e. 0 or 1
size_type count(const _Key& key) const {
return d_table.count(key);
}
// is the hash map empty?
bool empty() const {
return d_table.empty();
}
// the number of elements in the hash map
size_type size() const {
return d_table.size();
}
// the number of buckets in the hash map
size_type bucket_count() const {
return d_table.bucket_count();
}
// returns the average number of elements per bucket
float load_factor() const {
return d_table.load_factor();
}
/// iterators
// returns forward iterator to iterate over all key/data pairs
iterator begin() {
return d_table.begin();
}
// const version of begin
const_iterator begin() const {
return d_table.begin();
}
// returns end iterator
iterator end() {
return d_table.end();
}
// const version of end
const_iterator end() const {
return d_table.end();
}
};
}
#endif
|