_LIBCPP_HIDDEN __i_node* __libcpp_db::__insert_iterator(void* __i) { if (__isz_ + 1 > __iend_ - __ibeg_) { size_t nc = __next_prime(2*(__iend_ - __ibeg_) + 1); __i_node** ibeg = (__i_node**)calloc(nc, sizeof(void*)); if (ibeg == nullptr) throw bad_alloc(); for (__i_node** p = __ibeg_; p != __iend_; ++p) { __i_node* q = *p; while (q != nullptr) { size_t h = hash<void*>()(q->__i_) % nc; __i_node* r = q->__next_; q->__next_ = ibeg[h]; ibeg[h] = q; q = r; } } free(__ibeg_); __ibeg_ = ibeg; __iend_ = __ibeg_ + nc; } size_t hi = hash<void*>()(__i) % (__iend_ - __ibeg_); __i_node* p = __ibeg_[hi]; __i_node* r = __ibeg_[hi] = (__i_node*)malloc(sizeof(__i_node)); if (r == nullptr) throw bad_alloc(); ::new(r) __i_node(__i, p, nullptr); ++__isz_; return r; }
__c_node* __libcpp_db::__insert_c(void* __c) { #ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); #endif if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_)) { size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1); __c_node** cbeg = static_cast<__c_node**>(calloc(nc, sizeof(void*))); if (cbeg == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); #else abort(); #endif for (__c_node** p = __cbeg_; p != __cend_; ++p) { __c_node* q = *p; while (q != nullptr) { size_t h = hash<void*>()(q->__c_) % nc; __c_node* r = q->__next_; q->__next_ = cbeg[h]; cbeg[h] = q; q = r; } } free(__cbeg_); __cbeg_ = cbeg; __cend_ = __cbeg_ + nc; } size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; __c_node* r = __cbeg_[hc] = static_cast<__c_node*>(malloc(sizeof(__c_node))); if (__cbeg_[hc] == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); #else abort(); #endif r->__c_ = __c; r->__next_ = p; ++__csz_; return r; }
_LIBCPP_HIDDEN __i_node* __libcpp_db::__insert_iterator(void* __i) { if (__isz_ + 1 > static_cast<size_t>(__iend_ - __ibeg_)) { size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1); __i_node** ibeg = static_cast<__i_node**>(calloc(nc, sizeof(void*))); if (ibeg == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); #else abort(); #endif for (__i_node** p = __ibeg_; p != __iend_; ++p) { __i_node* q = *p; while (q != nullptr) { size_t h = hash<void*>()(q->__i_) % nc; __i_node* r = q->__next_; q->__next_ = ibeg[h]; ibeg[h] = q; q = r; } } free(__ibeg_); __ibeg_ = ibeg; __iend_ = __ibeg_ + nc; } size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_); __i_node* p = __ibeg_[hi]; __i_node* r = __ibeg_[hi] = static_cast<__i_node*>(malloc(sizeof(__i_node))); if (r == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); #else abort(); #endif ::new(r) __i_node(__i, p, nullptr); ++__isz_; return r; }
__c_node* __libcpp_db::__insert_c(void* __c) { WLock _(mut()); if (__csz_ + 1 > __cend_ - __cbeg_) { size_t nc = __next_prime(2*(__cend_ - __cbeg_) + 1); __c_node** cbeg = (__c_node**)calloc(nc, sizeof(void*)); if (cbeg == nullptr) throw bad_alloc(); for (__c_node** p = __cbeg_; p != __cend_; ++p) { __c_node* q = *p; while (q != nullptr) { size_t h = hash<void*>()(q->__c_) % nc; __c_node* r = q->__next_; q->__next_ = cbeg[h]; cbeg[h] = q; q = r; } } free(__cbeg_); __cbeg_ = cbeg; __cend_ = __cbeg_ + nc; } size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; __c_node* r = __cbeg_[hc] = (__c_node*)malloc(sizeof(__c_node)); if (__cbeg_[hc] == nullptr) throw bad_alloc(); r->__c_ = __c; r->__next_ = p; ++__csz_; return r; }