MCPcopy Create free account
hub / github.com/crownengine/crown / insert

Method insert

3rdparty/bx/include/tinystl/unordered_set.h:201–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199
200 template<typename Key, typename Alloc>
201 inline pair<typename unordered_set<Key, Alloc>::iterator, bool> unordered_set<Key, Alloc>::insert(const Key& key) {
202 pair<iterator, bool> result;
203 result.second = false;
204
205 result.first = find(key);
206 if (result.first.node != nullptr)
207 return result;
208
209 unordered_hash_node<Key, void>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, void>))) unordered_hash_node<Key, void>(key);
210 newnode->next = newnode->prev = nullptr;
211
212 if(!m_buckets.first) buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
213 const size_t nbuckets = (size_t)(m_buckets.last - m_buckets.first);
214 unordered_hash_node_insert(newnode, hash(key), m_buckets.first, nbuckets - 1);
215
216 ++m_size;
217 rehash(nbuckets);
218
219 result.first.node = newnode;
220 result.second = true;
221 return result;
222 }
223
224 template<typename Key, typename Alloc>
225 inline pair<typename unordered_set<Key, Alloc>::iterator, bool> unordered_set<Key, Alloc>::emplace(Key&& key) {

Callers

nothing calls this directly

Calls 5

placeholderClass · 0.85
hashFunction · 0.70
findFunction · 0.50
rehashFunction · 0.50

Tested by

no test coverage detected