// move the item under oldFinger to newFinger (assumed to be left of oldFinger) protected void ReInsert(ref RBFinger <T> oldFinger, RBFinger <T> newFinger) { RBNode <T> oldNode = oldFinger.Node, newNode = newFinger.Node; int oldOffset = oldFinger.Offset, newOffset = newFinger.Offset; T x = oldNode.GetItemAt(oldFinger.Offset); if (oldNode == newNode) { // move within a single node int s = oldOffset - newOffset; if (s != 0) { Copy(oldNode, newOffset, oldNode, newOffset + 1, s); oldNode.SetItemAt(newOffset, x); } } else { // move from one node to an earlier node if (newNode.Size < MaxSize) { // easy case - new node has room newNode.InsertAt(newOffset, x); oldNode.RemoveAt(ref oldFinger); } else { // hard case - new node is full RBNode <T> successor = newNode.GetSuccessor(); if (successor == oldNode) { // easy subcase - oldNode is next to newNode T y = newNode.GetItemAt(MaxSize - 1); Copy(newNode, newOffset, newNode, newOffset + 1, MaxSize - newOffset - 1); newNode.SetItemAt(newOffset, x); Copy(oldNode, 0, oldNode, 1, oldOffset); oldNode.SetItemAt(0, y); } else { if (successor.Size < MaxSize) { // medium subcase - need to move items into successor newNode.InsertAt(newOffset, x, successor); } else { // hard subcase - need a new node after newNode RBNode <T> succsucc = successor; successor = InsertNodeAfter(newNode); newNode.InsertAt(newOffset, x, successor, succsucc); } oldNode.RemoveAt(ref oldFinger); } } } }
// Token: 0x06007691 RID: 30353 RVA: 0x0021DF78 File Offset: 0x0021C178 protected void ReInsert(ref RBFinger <T> oldFinger, RBFinger <T> newFinger) { RBNode <T> node = oldFinger.Node; RBNode <T> node2 = newFinger.Node; int offset = oldFinger.Offset; int offset2 = newFinger.Offset; T itemAt = node.GetItemAt(oldFinger.Offset); if (node == node2) { int num = offset - offset2; if (num != 0) { this.Copy(node, offset2, node, offset2 + 1, num); node.SetItemAt(offset2, itemAt); return; } } else { if (node2.Size < 64) { node2.InsertAt(offset2, itemAt, null, null); node.RemoveAt(ref oldFinger); return; } RBNode <T> rbnode = node2.GetSuccessor(); if (rbnode == node) { T itemAt2 = node2.GetItemAt(63); this.Copy(node2, offset2, node2, offset2 + 1, 64 - offset2 - 1); node2.SetItemAt(offset2, itemAt); this.Copy(node, 0, node, 1, offset); node.SetItemAt(0, itemAt2); return; } if (rbnode.Size < 64) { node2.InsertAt(offset2, itemAt, rbnode, null); } else { RBNode <T> succsucc = rbnode; rbnode = this.InsertNodeAfter(node2); node2.InsertAt(offset2, itemAt, rbnode, succsucc); } node.RemoveAt(ref oldFinger); } }