• Home
  • Raw
  • Download

Lines Matching refs:hash

122 #define HASH_DELETE_KEY_VALUE(hash, keypointer, valuepointer) UPRV_BLOCK_MACRO_BEGIN { \  argument
123 if (hash->keyDeleter != NULL && keypointer != NULL) { \
124 (*hash->keyDeleter)(keypointer); \
126 if (hash->valueDeleter != NULL && valuepointer != NULL) { \
127 (*hash->valueDeleter)(valuepointer); \
146 _uhash_setElement(UHashtable *hash, UHashElement* e, in _uhash_setElement() argument
151 if (hash->keyDeleter != NULL && e->key.pointer != NULL && in _uhash_setElement()
153 (*hash->keyDeleter)(e->key.pointer); in _uhash_setElement()
155 if (hash->valueDeleter != NULL) { in _uhash_setElement()
158 (*hash->valueDeleter)(oldValue.pointer); in _uhash_setElement()
186 _uhash_internalRemoveElement(UHashtable *hash, UHashElement* e) { in _uhash_internalRemoveElement() argument
189 --hash->count; in _uhash_internalRemoveElement()
191 return _uhash_setElement(hash, e, HASH_DELETED, empty, empty, 0); in _uhash_internalRemoveElement()
195 _uhash_internalSetResizePolicy(UHashtable *hash, enum UHashResizePolicy policy) { in _uhash_internalSetResizePolicy() argument
196 U_ASSERT(hash != NULL); in _uhash_internalSetResizePolicy()
199 hash->lowWaterRatio = RESIZE_POLICY_RATIO_TABLE[policy * 2]; in _uhash_internalSetResizePolicy()
200 hash->highWaterRatio = RESIZE_POLICY_RATIO_TABLE[policy * 2 + 1]; in _uhash_internalSetResizePolicy()
213 _uhash_allocate(UHashtable *hash, in _uhash_allocate() argument
224 hash->primeIndex = static_cast<int8_t>(primeIndex); in _uhash_allocate()
225 hash->length = PRIMES[primeIndex]; in _uhash_allocate()
227 p = hash->elements = (UHashElement*) in _uhash_allocate()
228 uprv_malloc(sizeof(UHashElement) * hash->length); in _uhash_allocate()
230 if (hash->elements == NULL) { in _uhash_allocate()
238 limit = p + hash->length; in _uhash_allocate()
246 hash->count = 0; in _uhash_allocate()
247 hash->lowWaterMark = (int32_t)(hash->length * hash->lowWaterRatio); in _uhash_allocate()
248 hash->highWaterMark = (int32_t)(hash->length * hash->highWaterRatio); in _uhash_allocate()
336 _uhash_find(const UHashtable *hash, UHashTok key, in _uhash_find() argument
343 UHashElement *elements = hash->elements; in _uhash_find()
346 startIndex = theIndex = (hashcode ^ 0x4000000) % hash->length; in _uhash_find()
351 if ((*hash->keyComparator)(key, elements[theIndex].key)) { in _uhash_find()
369 jump = (hashcode % (hash->length - 1)) + 1; in _uhash_find()
371 theIndex = (theIndex + jump) % hash->length; in _uhash_find()
397 _uhash_rehash(UHashtable *hash, UErrorCode *status) { in _uhash_rehash() argument
399 UHashElement *old = hash->elements; in _uhash_rehash()
400 int32_t oldLength = hash->length; in _uhash_rehash()
401 int32_t newPrimeIndex = hash->primeIndex; in _uhash_rehash()
404 if (hash->count > hash->highWaterMark) { in _uhash_rehash()
408 } else if (hash->count < hash->lowWaterMark) { in _uhash_rehash()
416 _uhash_allocate(hash, newPrimeIndex, status); in _uhash_rehash()
419 hash->elements = old; in _uhash_rehash()
420 hash->length = oldLength; in _uhash_rehash()
426 UHashElement *e = _uhash_find(hash, old[i].key, old[i].hashcode); in _uhash_rehash()
432 ++hash->count; in _uhash_rehash()
440 _uhash_remove(UHashtable *hash, in _uhash_remove() argument
450 UHashElement* e = _uhash_find(hash, key, hash->keyHasher(key)); in _uhash_remove()
455 result = _uhash_internalRemoveElement(hash, e); in _uhash_remove()
456 if (hash->count < hash->lowWaterMark) { in _uhash_remove()
458 _uhash_rehash(hash, &status); in _uhash_remove()
465 _uhash_put(UHashtable *hash, in _uhash_put() argument
483 U_ASSERT(hash != NULL); in _uhash_put()
490 return _uhash_remove(hash, key); in _uhash_put()
492 if (hash->count > hash->highWaterMark) { in _uhash_put()
493 _uhash_rehash(hash, status); in _uhash_put()
499 hashcode = (*hash->keyHasher)(key); in _uhash_put()
500 e = _uhash_find(hash, key, hashcode); in _uhash_put()
511 ++hash->count; in _uhash_put()
512 if (hash->count == hash->length) { in _uhash_put()
514 --hash->count; in _uhash_put()
524 return _uhash_setElement(hash, e, hashcode & 0x7FFFFFFF, key, value, hint); in _uhash_put()
531 HASH_DELETE_KEY_VALUE(hash, key.pointer, value.pointer); in _uhash_put()
593 uhash_close(UHashtable *hash) { in uhash_close() argument
594 if (hash == NULL) { in uhash_close()
597 if (hash->elements != NULL) { in uhash_close()
598 if (hash->keyDeleter != NULL || hash->valueDeleter != NULL) { in uhash_close()
601 while ((e = (UHashElement*) uhash_nextElement(hash, &pos)) != NULL) { in uhash_close()
602 HASH_DELETE_KEY_VALUE(hash, e->key.pointer, e->value.pointer); in uhash_close()
605 uprv_free(hash->elements); in uhash_close()
606 hash->elements = NULL; in uhash_close()
608 if (hash->allocated) { in uhash_close()
609 uprv_free(hash); in uhash_close()
614 uhash_setKeyHasher(UHashtable *hash, UHashFunction *fn) { in uhash_setKeyHasher() argument
615 UHashFunction *result = hash->keyHasher; in uhash_setKeyHasher()
616 hash->keyHasher = fn; in uhash_setKeyHasher()
621 uhash_setKeyComparator(UHashtable *hash, UKeyComparator *fn) { in uhash_setKeyComparator() argument
622 UKeyComparator *result = hash->keyComparator; in uhash_setKeyComparator()
623 hash->keyComparator = fn; in uhash_setKeyComparator()
627 uhash_setValueComparator(UHashtable *hash, UValueComparator *fn){ in uhash_setValueComparator() argument
628 UValueComparator *result = hash->valueComparator; in uhash_setValueComparator()
629 hash->valueComparator = fn; in uhash_setValueComparator()
634 uhash_setKeyDeleter(UHashtable *hash, UObjectDeleter *fn) { in uhash_setKeyDeleter() argument
635 UObjectDeleter *result = hash->keyDeleter; in uhash_setKeyDeleter()
636 hash->keyDeleter = fn; in uhash_setKeyDeleter()
641 uhash_setValueDeleter(UHashtable *hash, UObjectDeleter *fn) { in uhash_setValueDeleter() argument
642 UObjectDeleter *result = hash->valueDeleter; in uhash_setValueDeleter()
643 hash->valueDeleter = fn; in uhash_setValueDeleter()
648 uhash_setResizePolicy(UHashtable *hash, enum UHashResizePolicy policy) { in uhash_setResizePolicy() argument
650 _uhash_internalSetResizePolicy(hash, policy); in uhash_setResizePolicy()
651 hash->lowWaterMark = (int32_t)(hash->length * hash->lowWaterRatio); in uhash_setResizePolicy()
652 hash->highWaterMark = (int32_t)(hash->length * hash->highWaterRatio); in uhash_setResizePolicy()
653 _uhash_rehash(hash, &status); in uhash_setResizePolicy()
657 uhash_count(const UHashtable *hash) { in uhash_count() argument
658 return hash->count; in uhash_count()
662 uhash_get(const UHashtable *hash, in uhash_get() argument
666 return _uhash_find(hash, keyholder, hash->keyHasher(keyholder))->value.pointer; in uhash_get()
670 uhash_iget(const UHashtable *hash, in uhash_iget() argument
674 return _uhash_find(hash, keyholder, hash->keyHasher(keyholder))->value.pointer; in uhash_iget()
678 uhash_geti(const UHashtable *hash, in uhash_geti() argument
682 return _uhash_find(hash, keyholder, hash->keyHasher(keyholder))->value.integer; in uhash_geti()
686 uhash_igeti(const UHashtable *hash, in uhash_igeti() argument
690 return _uhash_find(hash, keyholder, hash->keyHasher(keyholder))->value.integer; in uhash_igeti()
694 uhash_getiAndFound(const UHashtable *hash, in uhash_getiAndFound() argument
699 const UHashElement *e = _uhash_find(hash, keyholder, hash->keyHasher(keyholder)); in uhash_getiAndFound()
705 uhash_igetiAndFound(const UHashtable *hash, in uhash_igetiAndFound() argument
710 const UHashElement *e = _uhash_find(hash, keyholder, hash->keyHasher(keyholder)); in uhash_igetiAndFound()
716 uhash_put(UHashtable *hash, in uhash_put() argument
723 return _uhash_put(hash, keyholder, valueholder, in uhash_put()
729 uhash_iput(UHashtable *hash, in uhash_iput() argument
736 return _uhash_put(hash, keyholder, valueholder, in uhash_iput()
742 uhash_puti(UHashtable *hash, in uhash_puti() argument
749 return _uhash_put(hash, keyholder, valueholder, in uhash_puti()
756 uhash_iputi(UHashtable *hash, in uhash_iputi() argument
763 return _uhash_put(hash, keyholder, valueholder, in uhash_iputi()
769 uhash_putiAllowZero(UHashtable *hash, in uhash_putiAllowZero() argument
776 return _uhash_put(hash, keyholder, valueholder, in uhash_putiAllowZero()
783 uhash_iputiAllowZero(UHashtable *hash, in uhash_iputiAllowZero() argument
790 return _uhash_put(hash, keyholder, valueholder, in uhash_iputiAllowZero()
796 uhash_remove(UHashtable *hash, in uhash_remove() argument
800 return _uhash_remove(hash, keyholder).pointer; in uhash_remove()
804 uhash_iremove(UHashtable *hash, in uhash_iremove() argument
808 return _uhash_remove(hash, keyholder).pointer; in uhash_iremove()
812 uhash_removei(UHashtable *hash, in uhash_removei() argument
816 return _uhash_remove(hash, keyholder).integer; in uhash_removei()
820 uhash_iremovei(UHashtable *hash, in uhash_iremovei() argument
824 return _uhash_remove(hash, keyholder).integer; in uhash_iremovei()
828 uhash_removeAll(UHashtable *hash) { in uhash_removeAll() argument
831 U_ASSERT(hash != NULL); in uhash_removeAll()
832 if (hash->count != 0) { in uhash_removeAll()
833 while ((e = uhash_nextElement(hash, &pos)) != NULL) { in uhash_removeAll()
834 uhash_removeElement(hash, e); in uhash_removeAll()
837 U_ASSERT(hash->count == 0); in uhash_removeAll()
841 uhash_containsKey(const UHashtable *hash, const void *key) { in uhash_containsKey() argument
844 const UHashElement *e = _uhash_find(hash, keyholder, hash->keyHasher(keyholder)); in uhash_containsKey()
856 uhash_icontainsKey(const UHashtable *hash, int32_t key) { in uhash_icontainsKey() argument
859 const UHashElement *e = _uhash_find(hash, keyholder, hash->keyHasher(keyholder)); in uhash_icontainsKey()
864 uhash_find(const UHashtable *hash, const void* key) { in uhash_find() argument
868 e = _uhash_find(hash, keyholder, hash->keyHasher(keyholder)); in uhash_find()
873 uhash_nextElement(const UHashtable *hash, int32_t *pos) { in uhash_nextElement() argument
878 U_ASSERT(hash != NULL); in uhash_nextElement()
879 for (i = *pos + 1; i < hash->length; ++i) { in uhash_nextElement()
880 if (!IS_EMPTY_OR_DELETED(hash->elements[i].hashcode)) { in uhash_nextElement()
882 return &(hash->elements[i]); in uhash_nextElement()
891 uhash_removeElement(UHashtable *hash, const UHashElement* e) { in uhash_removeElement() argument
892 U_ASSERT(hash != NULL); in uhash_removeElement()
896 return _uhash_internalRemoveElement(hash, nce).pointer; in uhash_removeElement()