rename HashSet::resize to reserve

This commit is contained in:
James Cherry 2020-03-07 13:06:10 -08:00
parent 3a7c1a9c8f
commit ae61892d7d
2 changed files with 5 additions and 5 deletions

View File

@ -2662,7 +2662,7 @@ Search::findTagGroup(TagGroupBldr *tag_bldr)
tag_groups_ = new_tag_groups;
tag_group_capacity_ = new_capacity;
delete [] old_tag_groups;
tag_group_set_->resize(new_capacity);
tag_group_set_->reserve(new_capacity);
}
if (tag_group_next_ > tag_group_index_max)
internalError("max tag group index exceeded");
@ -2889,7 +2889,7 @@ Search::findTag(const RiseFall *rf,
tags_ = new_tags;
delete [] old_tags;
tag_capacity_ = new_capacity;
tag_set_->resize(new_capacity);
tag_set_->reserve(new_capacity);
}
if (tag_next_ > tag_index_max)
internalError("max tag index exceeded");

View File

@ -40,7 +40,7 @@ public:
// Number of hash buckets.
size_t capacity() const { return capacity_; }
// Multi-threaded findKey is safe during resize.
void resize(size_t capacity);
void reserve(size_t capacity);
void insert(KEY key);
KEY findKey(KEY key);
KEY findKey(KEY key) const;
@ -308,12 +308,12 @@ HashSet<KEY, HASH, EQUAL>::insert(KEY key)
size_++;
if (size_ > capacity_
&& auto_resize_)
resize(nextMersenne(capacity_));
reserve(nextMersenne(capacity_));
}
template <class KEY, class HASH, class EQUAL>
void
HashSet<KEY, HASH, EQUAL>::resize(size_t capacity)
HashSet<KEY, HASH, EQUAL>::reserve(size_t capacity)
{
if (capacity != capacity_) {
if (size_ == 0) {