26 #ifndef HASHTABLE_HPP_
27 #define HASHTABLE_HPP_ 1
110 template<
typename _Entry,
132 assert(initial_capacity > 0);
222 size_t hash = t.hash();
224 size_t perturb =
hash;
226 Entry *insert_pos = NULL;
227 bool occupied =
false;
241 }
else if (e->is_deleted() && !insert_pos) {
244 }
else if (*e == t) {
253 index = (5 *
index) + 1 + perturb;
258 return EntryRef(insert_pos, occupied);
328 if (ref->is_empty()) {
331 }
else if (ref->is_deleted()) {
337 ref->set_occupied(t);
345 template<
typename Key,
typename Val>
353 template<
typename Key,
typename Val>
361 template<
typename Key,
typename Val>
369 template<
typename Key,
typename Val>
383 void remove(EntryRef ref) {
400 void remove(
const T& t) {
432 assert(load_factor > 0);
433 assert(load_factor < 100);
447 if (begin != end && !begin->is_occupied())
450 return Iterator(begin, end);
481 for (
Entry *it = old_entries, *
end = old_entries + old_capacity; it !=
end; ++it) {
482 if (it->is_occupied()) {
488 size_t hash = it->hash();
490 size_t perturb =
hash;
502 index = (5 *
index) + 1 + perturb;
509 destroy(old_entries, old_capacity);
531 for (
Entry *it = es, *
end = it + sz; it !=
end; ++it) {
543 if (current == end)
return current;
547 }
while (current != end && !current->is_occupied());
582 template<
typename Value>
609 template<
typename T,
typename A>
616 template<
typename Value>
646 template<
typename T,
typename A>
666 template<
typename Value>
672 using Value::set_key;
676 size_t hash()
const {
return key().hash(); }
678 bool is_empty()
const {
return key() == (utf*) 0; }
689 template<
typename T,
typename A>
697 template<
typename Value>
704 using Value::set_key;
708 size_t hash()
const {
return key().hash(); }
710 bool is_empty()
const {
return key() == (utf*) 0; }
720 template<
typename T,
typename A>
796 #endif // HASHTABLE_HPP_
Iterator(Entry *pos, Entry *end)
NameValuePair(Utf8String name, Value v)
size_t hash() const
Interface to HashTable.
static const size_t DEFAULT_INITIAL_CAPACITY
Entry & update(const T &t)
HashTable(size_t initial_capacity, size_t load_factor=DEFAULT_LOAD_FACTOR)
bool operator==(Utf8String u) const
InsertOnlyNameValuePair()
static Entry * next_occupied(Entry *current, Entry *end)
Entry & insert(const T &t)
Dummy implementation of a mutex.
JNIEnv jclass jobject const char * name
NamedEntry(const Value &v)
static bool is_power_of_two(size_t n)
JNIEnv jthread jobject jclass jlong size
void set_occupied(const NameValuePair &n)
MachineBasicBlock * current
Entry & insert(EntryRef ref, const Key &k, const Val &v)
Utility function for hashtables that store key value pairs.
void set_occupied(const InsertOnlyNameValuePair &n)
Entry & insert(EntryRef ref, const T &t)
void hashtable_free(hashtable *hash)
Entry & insert(const Key &k, const Val &v)
Utility function for hashtables that store key value pairs.
EntryRef(Entry *e, bool occupied)
size_t hash() const
Interface to HashTable.
size_t hash() const
Interface to HashTable.
size_t hash() const
Interface to HashTable.
void set_load_factor(size_t load_factor)
static size_t fast_modulo(size_t n, size_t modul)
fast computation of n % m.
const Value & value() const
void destroy(Entry *es, size_t sz)
bool operator==(Utf8String u) const
Entry & update(const Key &k, const Val &v)
Utility function for hashtables that store key value pairs.
bool operator==(const InsertOnlyNameValuePair &n) const
bool operator==(const NameValuePair &n) const
hashtable * hashtable_resize(hashtable *hash, u4 size)
#define EXPENSIVE_ASSERT(EXPR)
An assertion that performs computations too expensive even for a normal debug build.
void grow_table(size_t new_capacity)
Increase capacity, re-allocate table and copy over all old entries.
EntryRef find(const T &t)
bool operator!=(Iterator it) const
Represents the result of the addition of a certain IR-variable with a certain constant.
Entry & update(EntryRef ref, const Key &k, const Val &v)
Utility function for hashtables that store key value pairs.
InsertOnlyNameValuePair(Utf8String name, Value v)
Entry & update(EntryRef ref, const T &t)
bool operator==(Utf8String u) const
static size_t next_power_of_two(size_t n)
find the smallest power of two >= n
bool operator==(const Value &v) const
InsertOnlyNamedEntry(const Value &v)
const Value & value() const
static const size_t DEFAULT_LOAD_FACTOR
void set_occupied(const NamedEntry &e)
HashTable & operator=(const HashTable &)
void hashtable_create(hashtable *hash, u4 size)
bool operator==(Iterator it) const
bool operator==(Utf8String u) const
bool operator==(const Value &v) const
void set_occupied(const Value &v)