MaxValue() public static method

public static MaxValue ( int width ) : uint
width int
return uint
Esempio n. 1
0
        public VEBTree(int width)
        {
            if (width > 32 || width < 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            this.width = width;
            if (width > 1)
            {
                int highHalf = width / 2 + (width & 1);
                int lowhHalf = width / 2;
                int halfSize = (int)BitHacks.MaxValue(highHalf) + 1;
                summary = new VEBTree <uint>(highHalf);
                cluster = new VEBTree <T> [halfSize];
                for (int i = 0; i < halfSize; i++)
                {
                    cluster[i] = new VEBTree <T>(lowhHalf);
                }
            }
        }
Esempio n. 2
0
        private void AddChecked(uint key, T value, bool overwrite)
        {
            var separator = Separator(key);

            if (separator == null)
            {
                // add first element
                RBTree newTree = new RBTree(Node.Helper);
                newTree.root = new RBUIntNode(key, value)
                {
                    IsBlack = true
                };
                cluster.Add(BitHacks.MaxValue(cluster.width), newTree);
                return;
            }
            RBUIntNode newNode  = new RBUIntNode(key, value);
            RBUIntNode interned = (RBUIntNode)separator.value.Intern(key, newNode);

            if (interned != newNode)
            {
                if (overwrite)
                {
                    interned.value = value;
                }
                else
                {
                    throw new ArgumentException();
                }
            }
            else
            {
                count++;
                version++;
            }
            SplitIfTooLarge(separator);
        }