public IntTree <V> AddOrUpdate(int key, V value, Update <V> updateValue = null) { return(Height == 0 ? new IntTree <V>(key, value, Empty, Empty) : (key == Key ? new IntTree <V>(key, updateValue == null ? value : updateValue(Value, value), Left, Right) : (key < Key ? With(Left.AddOrUpdate(key, value, updateValue), Right) : With(Left, Right.AddOrUpdate(key, value, updateValue))).EnsureBalanced())); }
public override AppendStore <T> Append(T value) { return(new TreeAppendStore(Count + 1, _tree.AddOrUpdate(Count >> NODE_ARRAY_BIT_COUNT, new[] { value }, ArrayTools.Append))); }