daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest May 12th, 2014 287 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. open System
  2. open System.Collections.Generic
  3. open Microsoft.FSharp.Core
  4. open Microsoft.FSharp.Collections
  5.  
  6. /// <summary>Immutable maps. Keys are ordered by F# generic comparison.</summary>
  7. ///
  8. /// <remarks>Map interface based on Microsoft.FSharp.Collections.Map
  9. /// (See: https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/map.fsi)</remarks>
  10. type Map<[<EqualityConditionalOn>]'Key,[<EqualityConditionalOn;ComparisonConditionalOn>]'Value when 'Key : comparison> =
  11.  interface
  12.    /// <summary>Returns a new map with the binding added to the given map.</summary>
  13.    /// <param name="key">The input key.</param>
  14.    /// <returns>The resulting map.</returns>
  15.    abstract member Add: key:'Key * value:'Value -> Map<'Key,'Value>
  16.  
  17.    /// <summary>Returns true if there are no bindings in the map.</summary>
  18.    abstract member IsEmpty: bool
  19.  
  20.    //TODO:
  21.    /// <summary>Builds a map that contains the bindings of the given IEnumerable.</summary>
  22.    /// <param name="elements">The input sequence of key/value pairs.</param>
  23.    /// <returns>The resulting map.</returns>
  24.    //new : elements:seq<'Key * 'Value> -> Map<'Key,'Value>
  25.  
  26.    /// <summary>Tests if an element is in the domain of the map.</summary>
  27.    /// <param name="key">The input key.</param>
  28.    /// <returns>True if the map contains the given key.</returns>
  29.    abstract member ContainsKey: key:'Key -> bool
  30.  
  31.     /// <summary>The number of bindings in the map.</summary>
  32.     abstract member Count: int
  33.  
  34.     /// <summary>Lookup an element in the map. Raise <c>KeyNotFoundException</c> if no binding
  35.     /// exists in the map.</summary>
  36.     /// <param name="key">The input key.</param>
  37.     /// <exception cref="System.Collections.Generic.KeyNotFoundException">Thrown when the key is not found.</exception>
  38.     /// <returns>The value mapped to the key.</returns>
  39.     abstract member Item : key:'Key -> 'Value with get
  40.  
  41.     /// <summary>Removes an element from the domain of the map. No exception is raised if the element is not present.</summary>
  42.     /// <param name="key">The input key.</param>
  43.     /// <returns>The resulting map.</returns>
  44.     abstract member Remove: key:'Key -> Map<'Key,'Value>
  45.  
  46.    /// <summary>Lookup an element in the map, returning a <c>Some</c> value if the element is in the domain
  47.    /// of the map and <c>None</c> if not.</summary>
  48.    /// <param name="key">The input key.</param>
  49.    /// <returns>The mapped value, or None if the key is not in the map.</returns>
  50.    abstract member TryFind: key:'Key -> 'Value option
  51.  
  52.    inherit IEnumerable<KeyValuePair<'Key, 'Value>>        
  53.  
  54.    //TODO:
  55.    //override Equals : obj -> bool
  56.  
  57.    //Optional:
  58.    //inherit IDictionary<'Key, 'Value>        
  59.    //inherit ICollection<KeyValuePair<'Key, 'Value>>
  60.    //inherit System.IComparable
  61.    //inherit System.Collections.IEnumerable
  62.  end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top