SpiecsEngine
 
Loading...
Searching...
No Matches

◆ set()

template<size_t BITS>
void scl::radix_trie< BITS, 3 >::set ( size_t k,
void * v )
inline

Set pair of key - value.

Parameters
[in]kkey.
[in]vvalue.

Definition at line 317 of file RadixTrie.h.

318 {
319 assert(k >> BITS == 0);
320
321 const size_t i1 = k >> (LEAF_BITS + INTERIOR_BITS);
322 const size_t i2 = (k >> LEAF_BITS) & (INTERIOR_LENGTH - 1);
323 const size_t i3 = k & (LEAF_LENGTH - 1);
324
328
329 if (!m_Root->ptrs[i1])
330 {
332 }
333
334 if (!m_Root->ptrs[i1]->ptrs[i2])
335 {
336 m_Root->ptrs[i1]->ptrs[i2] = reinterpret_cast<Node*>(m_LeafPool.New());
337 }
338
339 reinterpret_cast<Leaf*>(m_Root->ptrs[i1]->ptrs[i2])->values[i3] = v;
340 }
T * New()
Alloc a memory block to store T.
Definition ObjectPool.h:177
static constexpr size_t LEAF_LENGTH
leaf array length.
Definition RadixTrie.h:243
void * get(size_t k) const
Get item by key.
Definition RadixTrie.h:298
Node * m_Root
Root Node.
Definition RadixTrie.h:264
static constexpr size_t INTERIOR_LENGTH
interior array length.
Definition RadixTrie.h:233
Spices::ObjectPool< Leaf > m_LeafPool
ObjectPool of Leaf.
Definition RadixTrie.h:274
static constexpr size_t INTERIOR_BITS
interior bits.
Definition RadixTrie.h:228
Spices::ObjectPool< Node > m_NodePool
ObjectPool of Node.
Definition RadixTrie.h:269
static constexpr size_t LEAF_BITS
leaf bits.
Definition RadixTrie.h:238
std::array< Node *, INTERIOR_LENGTH > ptrs
Definition RadixTrie.h:250