internal sealed override PersistentHashMap <K, V> Set(uint h, int s, KeyValueNode <K, V> n) { // TODO: Optimize if h,k and v are identical? // No need to check for reference equality as parent always creates new KeyValueNode if (Hash == h && Key.Equals(n.Key)) { // Replaces current node return(n); } else if (Hash == h) { return(HashCollisionNodeN <K, V> .FromTwoNodes(h, this, n)); } else { return(BitmapNodeN <K, V> .FromTwoNodes(s, Hash, this, h, n)); } }
internal sealed override PersistentHashMap <K, V> Set(uint h, int s, KeyValueNode <K, V> n) { if (Hash == h) { var k = n.Key; for (var iter = 0; iter < KeyValues.Length; ++iter) { if (KeyValues[iter].Key.Equals(k)) { var rvs = CopyArray(KeyValues); rvs[iter] = n; return(new HashCollisionNodeN <K, V> (h, rvs)); } } return(new HashCollisionNodeN <K, V> (h, CopyArrayMakeHoleLast(KeyValues, n))); } else { return(BitmapNodeN <K, V> .FromTwoNodes(s, Hash, this, h, n)); } }