public override object DeleteKeyForLeafNode(IKeyAndValue keyAndValue) { var objectHasBeenFound = false; var positionOfKey = GetPositionOfKey(keyAndValue.GetKey()); if (positionOfKey < 0) { return(null); } var realPosition = positionOfKey - 1; // In Multiple Values per key, the value is a list var value = (IList)Values[realPosition]; // Here we must search for the right object. The list can contains more than 1 object var size = value.Count; for (var i = 0; i < size && !objectHasBeenFound; i++) { if (!value[i].Equals(keyAndValue.GetValue())) { continue; } value.Remove(i); objectHasBeenFound = true; } if (!objectHasBeenFound) { return(null); } // If after removal, the list is empty, then remove the key from the node if (value.Count == 0) { // If we get there LeftShiftFrom(realPosition, false); NbKeys--; } BTreeValidator.ValidateNode(this); return(keyAndValue.GetValue()); }
public override object DeleteKeyForLeafNode(IKeyAndValue keyAndValue) { var objectHasBeenFound = false; var positionOfKey = GetPositionOfKey(keyAndValue.GetKey()); if (positionOfKey < 0) return null; var realPosition = positionOfKey - 1; // In Multiple Values per key, the value is a list var value = (IList) Values[realPosition]; // Here we must search for the right object. The list can contains more than 1 object var size = value.Count; for (var i = 0; i < size && !objectHasBeenFound; i++) { if (!value[i].Equals(keyAndValue.GetValue())) continue; value.Remove(i); objectHasBeenFound = true; } if (!objectHasBeenFound) { return null; } // If after removal, the list is empty, then remove the key from the node if (value.Count == 0) { // If we get there LeftShiftFrom(realPosition, false); NbKeys--; } BTreeValidator.ValidateNode(this); return keyAndValue.GetValue(); }
public virtual void SetKeyAndValueAt(IKeyAndValue keyAndValue, int index, bool shiftIfAlreadyExist, bool incrementNbKeys) { SetKeyAndValueAt(keyAndValue.GetKey(), keyAndValue.GetValue(), index, shiftIfAlreadyExist, incrementNbKeys); }
public virtual void SetKeyAndValueAt(IKeyAndValue keyAndValue, int index) { SetKeyAndValueAt(keyAndValue.GetKey(), keyAndValue.GetValue(), index); }