public INode assoc(int shift, int hash, object key, object val, Box addedLeaf) { int idx = Util.Mask(hash, shift); INode n = _nodes[idx].assoc(shift + 5, hash, key, val, addedLeaf); if (n == _nodes[idx]) { return(this); } else { INode[] newNodes = (INode[])_nodes.Clone(); newNodes[idx] = n; return(new FullNode(newNodes, shift)); } }
public INode without(int hash, object key) { int idx = Util.Mask(hash, _shift); INode n = _nodes[idx].without(hash, key); if (n != _nodes[idx]) { if (n == null) { INode[] newnodes1 = new INode[_nodes.Length - 1]; Array.Copy(_nodes, 0, newnodes1, 0, idx); Array.Copy(_nodes, idx + 1, newnodes1, idx, _nodes.Length - (idx + 1)); return(new BitmapIndexedNode(~bitpos(hash, _shift), newnodes1, _shift)); } INode[] newnodes = (INode[])_nodes.Clone(); newnodes[idx] = n; return(new FullNode(newnodes, _shift)); } return(this); }
static int bitpos(int hash, int shift) { return(1 << Util.Mask(hash, shift)); }
public INode find(int hash, object key) { return(_nodes[Util.Mask(hash, _shift)].find(hash, key)); }