diff --git a/src/FSharpAux.Core/Dictionary.fs b/src/FSharpAux.Core/Dictionary.fs index c8c2a7a..24a6116 100644 --- a/src/FSharpAux.Core/Dictionary.fs +++ b/src/FSharpAux.Core/Dictionary.fs @@ -117,6 +117,20 @@ module Dictionary = | true -> Some v | false -> None + /// Performs a shallow copy of the input dictionary + /// The input dictionary. + /// A shallow copy of the dictionary. + let copy (table: IDictionary<'k,'v>) = new Dictionary<'k,'v>(table) + + /// Performs a deep copy of the input dictionary + /// The input dictionary. + /// A deep copy of the dictionary. + let deepCopy (table: IDictionary<'k,'v> when 'v :> ICloneable) = + let ret = new Dictionary<'k,'v>(table.Count) + for entry in table do + ret.Add(entry.Key, entry.Value.Clone() :?> 'v ) + ret + // /// Folds over the bindings in the dictionary // /// The function to update the state given the input key/value pairs.