+ /// Changes the weight of the first node with the given key to the
+ /// new weight.
+ void change_weight(iterator & it, weight_type w)
+ {
+ node *n = root;
+ if (!n) return;
+ if (it.weight() == w)
+ return;
+
+ while(!n->isleafnode())
+ {
+ const inner_node *inner = static_cast<const inner_node*>(n);
+ int slot = find_lower(inner, it.key());
+
+ // two step because weight_type might be unsigned
+ n->weight -= it.weight();
+ n->weight += w;
+
+ n = inner->childid[slot];
+ }
+
+ BTREE_ASSERT(n == it.curnode);
+ n->weight -= it.weight();
+ n->weight += w;
+ it.currnode->weights[it.currslot] = w;
+ }
+