MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / insert

Method insert

src/semiorderedset.h:139–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 }
138
139 void insert(const T &e, bool fRehash = false)
140 {
141 if (!fRehash)
142 RehashStep();
143
144 auto idx = idxFromObj(static_cast<T_KEY>(e));
145 if (!fRehash)
146 ++celem;
147
148 if (m_data[idx] == nullptr)
149 m_data[idx] = std::make_shared<vector_type>();
150
151 typename vector_type::iterator itrInsert;
152 if (!m_data[idx]->empty() && !(e < m_data[idx]->back()))
153 itrInsert = m_data[idx]->end();
154 else
155 itrInsert = std::upper_bound(m_data[idx]->begin(), m_data[idx]->end(), e);
156 itrInsert = m_data[idx]->insert(itrInsert, e);
157
158 if (celem > ((1ULL << bits)*targetElementsPerBucket()))
159 grow();
160 }
161
162 // enumeration starting from the 'itrStart'th key. Note that the iter is a hint, and need no be valid anymore
163 template<typename T_VISITOR, typename T_MAX>

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected