void initialize_node(node_type *p, const value_type &v){ p->value = p->cache = v; p->modifier = m_traits.default_modifier(); p->priority = xorshift128(); p->size = 1; p->children[0] = p->children[1] = nullptr; }
void propagate(node_type *p) const { if(p == nullptr){ return; } const size_t k = size(p->children[0]); const auto mod_l_cr = m_traits.split_modifier(p->modifier, k); const auto mod_c_r = m_traits.split_modifier(mod_l_cr.second, 1); if(p->children[0] != nullptr){ p->children[0]->modifier = m_traits.merge_modifier( p->children[0]->modifier, mod_l_cr.first); refresh(p->children[0]); } if(p->children[1] != nullptr){ p->children[1]->modifier = m_traits.merge_modifier( p->children[1]->modifier, mod_c_r.second); refresh(p->children[1]); } p->value = m_traits.resolve(1, p->value, mod_c_r.first); p->modifier= m_traits.default_modifier(); }