public CPBNode(CPBNode <T> copy) { for (int i = 0; i < _children.Length; i++) { if (copy._children[i] != null) { _children[i] = (CPSNode <T>)copy._children[i].CloneAndOptimize(); } } _zlk = copy._zlk; _localCount = copy._localCount; }
private void ConvertToBOrSNode(ref CPNode <T> self, int extraCells) { if (_localCount < 32) { self = new CPSNode <T>(_localCount + extraCells); } else { self = new CPBNode <T>(); } // Scan key-value pairs in this node KeyWalker kw = new KeyWalker(new byte[1], 1); for (int section = 0; section < 8; section++) { uint f = _flags[section]; if (f == 0) { continue; } for (int i = MathEx.FindFirstOne(f); i < 32; i++) { if ((f & (1 << i)) != 0) // IsPresent(k) { // Get the key and value int k = (section << 5) + i; kw.Buffer[0] = (byte)k; T value = default(T); if (_values != null) { int P = GetValueIndex(k); if (P < _values.Length) { value = _values[P]; } } // Assign them to the new node bool existed = self.Set(ref kw, ref value, ref self, CPMode.Create | CPMode.FixedStructure); Debug.Assert(!existed); kw.Reset(); } } } }