elem *cilkred_map::insert_no_rehash(__cilkrts_worker *w, void *key, __cilkrts_hyperobject_base *hb, void *val) { #if REDPAR_DEBUG >= 2 fprintf(stderr, "[W=%d, desc=insert_no_rehash, this_map=%p]\n", w->self, this); verify_current_wkr(w); #endif CILK_ASSERT((w == 0 && g == 0) || w->g == g); CILK_ASSERT(key != 0); CILK_ASSERT(val != 0); elem *el = grow(w, &(buckets[hashfun(this, key)])); #if REDPAR_DEBUG >= 3 fprintf(stderr, "[W=%d, this=%p, inserting key=%p, val=%p, el = %p]\n", w->self, this, key, val, el); #endif el->key = key; el->hb = hb; el->val = val; ++nelem; return el; }
size_t operator() (const std::string& s) const { std::string cs = s; std::transform(cs.begin(), cs.end(), cs.begin(), ::tolower); std::hash<std::string> hashfun; return hashfun(cs); }
elem *cilkred_map::lookup(void *key) { bucket *b = buckets[hashfun(this, key)]; if (b) { elem *el; for (el = b->el; el->key; ++el) { if (el->key == key) { CILK_ASSERT(el->val); return el; } } } return 0; }
void bounded_set<Key, Hash, bound>::insert(Key key) { #ifdef SET_STATISTIC request++; #endif size_t hash = hashfun(key) & (bound-1); while (buckets[hash].next != nullptr and buckets[hash].key != key) { hash = hash < bound-1 ? hash+1 : 0; #ifdef SET_STATISTIC collide++; #endif } if (buckets[hash].next == nullptr) { #ifdef SET_STATISTIC success++; #endif buckets[hash].key = key; buckets[hash].next = first; first = &(buckets[hash]); } }