mirror of
https://github.com/bkaradzic/bx.git
synced 2026-09-06 18:38:36 +00:00
tinystl: reset() keeps the bucket table; clear() still shrinks to 9. (#419)
This commit is contained in:
committed by
GitHub
parent
9f874936e2
commit
671a001d3e
@@ -57,6 +57,7 @@ namespace tinystl {
|
||||
const_iterator end() const;
|
||||
|
||||
void clear();
|
||||
void reset();
|
||||
bool empty() const;
|
||||
size_t size() const;
|
||||
|
||||
@@ -180,6 +181,13 @@ namespace tinystl {
|
||||
|
||||
template<typename Key, typename Value, typename Alloc>
|
||||
inline void unordered_map<Key, Value, Alloc>::clear() {
|
||||
reset();
|
||||
m_buckets.last = m_buckets.first;
|
||||
buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
|
||||
}
|
||||
|
||||
template<typename Key, typename Value, typename Alloc>
|
||||
inline void unordered_map<Key, Value, Alloc>::reset() {
|
||||
if (m_buckets.first) {
|
||||
pointer it = *m_buckets.first;
|
||||
while (it) {
|
||||
@@ -189,10 +197,10 @@ namespace tinystl {
|
||||
|
||||
it = next;
|
||||
}
|
||||
|
||||
buffer_fill_urange(m_buckets.first, m_buckets.last, pointer(0));
|
||||
}
|
||||
|
||||
m_buckets.last = m_buckets.first;
|
||||
buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace tinystl {
|
||||
iterator end() const;
|
||||
|
||||
void clear();
|
||||
void reset();
|
||||
bool empty() const;
|
||||
size_t size() const;
|
||||
|
||||
@@ -154,6 +155,13 @@ namespace tinystl {
|
||||
|
||||
template<typename Key, typename Alloc>
|
||||
inline void unordered_set<Key, Alloc>::clear() {
|
||||
reset();
|
||||
m_buckets.last = m_buckets.first;
|
||||
buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
|
||||
}
|
||||
|
||||
template<typename Key, typename Alloc>
|
||||
inline void unordered_set<Key, Alloc>::reset() {
|
||||
if (m_buckets.first) {
|
||||
pointer it = *m_buckets.first;
|
||||
while (it) {
|
||||
@@ -163,10 +171,10 @@ namespace tinystl {
|
||||
|
||||
it = next;
|
||||
}
|
||||
|
||||
buffer_fill_urange(m_buckets.first, m_buckets.last, pointer(0));
|
||||
}
|
||||
|
||||
m_buckets.last = m_buckets.first;
|
||||
buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user