SpiecsEngine
 
Loading...
Searching...
No Matches

◆ set()

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

Set pair of key - value.

Parameters
[in]kkey.
[in]vvalue.

Definition at line 197 of file RadixTrie.h.

198 {
199 assert(k >> BITS == 0);
200
201 const size_t i1 = k >> LEAF_BITS;
202 const size_t i2 = k & (LEAF_LENGTH - 1);
203
206
207 if (!m_Root->ptrs[i1])
208 {
209 m_Root->ptrs[i1] = reinterpret_cast<Node*>(m_LeafPool.New());
210 }
211
212 reinterpret_cast<Leaf*>(m_Root->ptrs[i1])->values[i2] = v;
213 }
T * New()
Alloc a memory block to store T.
Definition ObjectPool.h:177
void * get(size_t k) const
Get item by key.
Definition RadixTrie.h:179
Node * m_Root
Root Node.
Definition RadixTrie.h:145
static constexpr size_t LEAF_BITS
leaf bits.
Definition RadixTrie.h:119
static constexpr size_t LEAF_LENGTH
leaf array length.
Definition RadixTrie.h:124
Spices::ObjectPool< Leaf > m_LeafPool
ObjectPool of Leaf.
Definition RadixTrie.h:150
static constexpr size_t ROOT_LENGTH
root array length.
Definition RadixTrie.h:114
std::array< Node *, ROOT_LENGTH > ptrs
Definition RadixTrie.h:131