Mask() public static method

public static Mask ( int hash, int shift ) : int
hash int
shift int
return int
Exemplo n.º 1
0
            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));
                }
            }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
 static int bitpos(int hash, int shift)
 {
     return(1 << Util.Mask(hash, shift));
 }
Exemplo n.º 4
0
 public INode find(int hash, object key)
 {
     return(_nodes[Util.Mask(hash, _shift)].find(hash, key));
 }