anchor.diff:              match trie with
               | Empty -> true
               | _ -> false
  +
  +    /// Look up an element in the IntMap returning a Some value if the
  +    /// element is in the domain of the IntMap and None if not.
  +    member __.TryFind (key : int) : 'T option =
  +        PatriciaMap.TryFind (uint32 key, trie)
  +
  +    /// Look up an element in the IntMap, raising KeyNotFoundException
  +    /// if no binding exists in the IntMap.
  +    member __.Find (key : int) : 'T =
  +        match PatriciaMap.TryFind (uint32 key, trie) with
  +        | Some x -> x
  +        | None ->
  +            // TODO : Add a better error message which includes the key.
  +            raise <| System.Collections.Generic.KeyNotFoundException ()
  +
  +    /// Returns a new IntMap with the binding added to this IntMap.
  +    member __.Add (key : int) (value : 'T) : IntMap<'T> =
  +        IntMap (
  +            PatriciaMap.Insert (uint32 key, value, trie))
  +
  +    /// Removes an element from the domain of the IntMap.
  +    /// No exception is raised if the element is not present.
  +    member __.Remove (key : int) : IntMap<'T> =
  +        IntMap (
  +            PatriciaMap.Remove (uint32 key, trie))
  +
  +    /// Tests if an element is in the domain of the IntMap.
  +    member __.ContainsKey (key : int) : bool =
  +        PatriciaMap.ContainsKey (uint32 key, trie)
  +
  +    /// The IntMap containing the given binding.
  +    static member Singleton (key : int, value : 'T) : IntMap<'T> =
  +        IntMap (
  +            Lf (uint32 key, value))
   
   //
   [<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  
positive.code:                 // The prefixes disagree.
                  PatriciaMap.Join (p, s, q, t)
  
  //
  [<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  module internal PatriciaMap =
      //
      let rec lookup (k, t) =
          match t with
          | Empty ->
              None
          | Lf (j, x) ->
              if j = k then Some x
              else None
          | Br (p, m, t0, t1) ->
              lookup (k, (if k <= p then t0 else t1))
  
      //
      let rec containsKey (k, t) =
          match t with
          | Empty ->
              false
          | Lf (j, _) ->
              k = j
          | Br (_, m, t0, t1) ->
              containsKey
                  (k, (if zeroBit (k, m) then t0 else t1))
  
      //
      let count t =
          // OPTIMIZE : We can 'strictify' this by adding an accumulator argument, so we'll
          // only need to use continuations for one side of the tree (left or right child).
          // We may also be able to eliminate continuations altogether by using an explicit
          // stack (either an F# list or System.Collections.Generic.Stack<'T>).
          let rec count (t : PatriciaMap<'T>) cont =
              match t with
              | Empty ->
                  cont 0
              | Lf (_,_) ->
                  cont 1
              | Br (_, _, left, right) ->
                  count left <| fun leftCount ->
                  count right <| fun rightCount ->
                      leftCount + rightCount
                      |> cont
  
          // Call the recursive implementation.
          count t id
  
      // TODO : This is an experimental version of count which is optimized for performance.
      // It should work, but we need to do some tests to be sure. Once we're confident it's correct
      // we'll remove the original 'count' function and use this once instead.
      let fastCount t =
          match t with
          | Empty -> 0u
          | Lf (_,_) -> 1u
          | Br (_,_,_,_) as t ->
              // TODO : Run some experiments to determine if this is a good initial capacity,
              // or if there is a more suitable value.
              let stack = System.Collections.Generic.Stack (64)
  
              // Add the initial tree to the stack.
              stack.Push t
  
              /// Recursively processes the tree using the mutable stack.
              let rec fastCount acc =
                  if stack.Count = 0 then acc
                  else
                      match stack.Pop () with
                      | Empty ->
                          fastCount acc
                      | Lf (_,_) ->
                          fastCount (acc + 1u)
                      
                      (* OPTIMIZATION :   When one or both children of this node are leaves, we handle
                                          them directly since it's a little faster. *)
                      | Br (_, _, Lf (_,_), Lf (_,_)) ->
                          fastCount (acc + 2u)
                      
                      | Br (_, _, Lf (_,_), child)
                      | Br (_, _, child, Lf (_,_)) ->
                          stack.Push child
                          fastCount (acc + 1u)
  
                      | Br (_, _, left, right) ->
                          // Push both children onto the stack and recurse to process them.
                          stack.Push left
                          stack.Push right
                          fastCount acc
  
              fastCount 0u
  
      //
      let rec remove (k, t) =
          match t with
          | Empty ->
              Empty
          | Lf (j, _) ->
              if j = k then Empty
              else t
          
          | Br (p, m, t0, t1) ->
              if matchPrefix (k, p, m) then
                  if zeroBit (k, m) then
                      match remove (k, t0) with
                      | Empty -> t1
                      | t0 ->
                          Br (p, m, t0, t1)
                  else
                      match remove (k, t1) with
                      | Empty -> t0
                      | t1 ->
                          Br (p, m, t0, t1)
              else t
  
      //
      let private join (p0, t0 : PatriciaMap<'T>, p1, t1) =
          let m = branchingBit (p0, p1)
          if zeroBit (p0, m) then
              Br (mask (p0, m), m, t0, t1)
          else
              Br (mask (p0, m), m, t1, t0)
  
      //
      let insert (k, x : 'T, t) =
          let rec ins = function
              | Empty ->
                  Lf (k, x)
              | Lf (j, y) as t ->
                  let newLeaf = Lf (k, x)
                  if j = k then
                      newLeaf
                  else
                      join (k, newLeaf, j, t)
  
              | Br (p, m, t0, t1) as t ->
                  if matchPrefix (k, p, m) then
                      if zeroBit (k, m) then
                          Br (p, m, ins t0, t1)
                      else
                          Br (p, m, t0, ins t1)
                  else
                      join (k, Lf (k, x), p, t)
  
          // Call the implementation function.
          ins t
  
      //
      let rec merge (s, t) : PatriciaMap<'T> =
          match s, t with
          | Empty, t
          | t, Empty ->
              t
          | Lf (k, x), t ->
              insert (k, x, t)
          | (Br (p, m, s0, s1) as s), Lf (k, x) ->
              if matchPrefix (k, p, m) then
                  if zeroBit (k, m) then
                      Br (p, m, insert (k, x, s0), s1)
                  else
                      Br (p, m, s0, insert (k, x, s1))
              else
                  join (k, Lf (k, x), p, s)
  
          | (Br (p, m, s0, s1) as s), (Br (q, n, t0, t1) as r) ->
              if m = n && p = q then
                  // The trees have the same prefix. Merge the subtrees.
                  Br (p, m, merge (s0, t0), merge (s1, t1))
                  
              elif m < n && matchPrefix (q, p, m) then
                  // q contains p. Merge t with a subtree of s.
                  if zeroBit (q, m) then
                      Br (p, m, merge (s0, t), s1)
                  else
                      Br (p, m, s0, merge (s1, t))
  
              elif m > n && matchPrefix (p, q, n) then
                  // p contains q. Merge s with a subtree of t.
                  if zeroBit (p, n) then
                      Br (q, n, merge (s, t0), t1)
                  else
                      Br (q, n, t0, merge (s, t1))
              else
                  // The prefixes disagree.
                  join (p, s, q, t)
  
  
  //
  [<Sealed>]
  
negative.code:         with get () : IntMap<'T> =
              IntMap Empty
  
      /// The number of bindings in the IntMap.
      member __.Count
          with get () : int =
              PatriciaMap.Count trie
  
      /// Is the map empty?
      member __.IsEmpty
  