anchor.diff: -﻿/// vector implementation ported from https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentMap.java
  +﻿// vector implementation ported from https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentMap.java
   
   namespace FSharpx.Collections
   
   open System.Threading
   open System.Collections.Generic
   
  -type Box(value:obj) =
  +type internal Box(value:obj) =
       member val Value = value with get, set
   
  -type INode =
  +type internal INode =
       abstract member assoc : int * int * obj  * obj * Box -> INode
       abstract member assoc : Thread ref * int * int * obj  * obj * Box -> INode
       abstract member find : int * int * obj -> obj
  
positive.code: 
      member this.Add(key:'T, value:'S) =
          if key = Unchecked.defaultof<'T> then
              if hasNull && value = nullValue then this else
              let count = if hasNull then count else count + 1
              PersistentHashMap<'T, 'S>(count, root, true, value)
          else 
              let addedLeaf = Box(null)
              let newroot =
                  (if root = Unchecked.defaultof<INode> then BitmapIndexedNode() :> INode else root)
                      .assoc(0, hash(key), key, value, addedLeaf) 
  
              if newroot = root then this else
              let count = if addedLeaf.Value = null then count else count + 1
              PersistentHashMap(count, newroot, hasNull, nullValue)
  
      member this.Remove(key:'T) =
          if key = Unchecked.defaultof<'T> then
              if hasNull then PersistentHashMap(count - 1, root, false, Unchecked.defaultof<'S>) else this
          else 
              if root = Unchecked.defaultof<INode> then this else
              let newroot = root.without(0, hash(key), key)
              if newroot = root then this else
              PersistentHashMap(count - 1, newroot, hasNull, nullValue)
  
      member this.Item 
          with get key = 
              if key = Unchecked.defaultof<'T> then 
                  if hasNull then nullValue else failwith "Key null is not found in the map."
              else
                  if root = Unchecked.defaultof<INode> then
                      failwithf "Key %A is not found in the map." key 
                  else 
                      match root.tryFind(0, hash(key), key) with
                      | Some value -> value :?> 'S
                      | _ -> failwithf "Key %A is not found in the map." key
  
      member this.Iterator<'T,'S>() : ('T * 'S) seq =
          seq {            
              if hasNull then yield Unchecked.defaultof<'T>, nullValue
              if root <> Unchecked.defaultof<INode> then
                  yield!
                      root.nodeSeq()
                      |> Seq.map (fun (key,value) -> key :?> 'T,value :?> 'S)
          }
  
  
negative.code:         thread := null
          PersistentHashMap(this.count, this.root, this.hasNull, this.nullValue)
  
  and PersistentHashMap<[<EqualityConditionalOn>]'T, 'S when 'T : equality and 'S : equality>  =
     val private count: int
     val private root:INode
     val private hasNull:bool
     val private nullValue:'S
  
      static member Empty() : PersistentHashMap<'T, 'S> = PersistentHashMap(0, Unchecked.defaultof<INode>, false, Unchecked.defaultof<'S>)
      member this.Length : int = this.count
  
      internal new (count',root':INode,hasNull', nullValue':'S) = {
          count = count'
          root = root'
          hasNull = hasNull'
          nullValue = nullValue' }
  
      member this.ContainsKey (key:'T) =
          if key = Unchecked.defaultof<'T> then this.hasNull else
          if this.root = Unchecked.defaultof<INode> then false else
          this.root.find(0, hash(key), key) <> null
  
      static member ofSeq(items:('T*'S) seq) =
          let mutable ret = TransientHashMap<'T,'S>.Empty()
  