BitsetsNET.RoaringArray.GetIndex C# (CSharp) Метод

GetIndex() публичный Метод

public GetIndex ( ushort x ) : int
x ushort
Результат int
        public int GetIndex(ushort x)
        {
            //TODO: optimize this
            //before the binary search we optimize for frequent cases
            if ((Size == 0) || (keys[Size - 1] == x))
            {
                return Size - 1;
            }
            return this.BinarySearch(0, Size, x);
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Adds the specified value to the current bitmap
        /// </summary>
        /// <param name="x">Value to be added</param>
        public void Add(int x)
        {
            ushort highBits       = Utility.GetHighBits(x);
            int    containerIndex = containers.GetIndex(highBits);

            if (containerIndex >= 0)
            {
                // a container exists at this index already.
                // find the right container, get the low order bits to add to the container and add them
                containers.SetContainerAtIndex(containerIndex, containers.GetContainerAtIndex(containerIndex).Add(Utility.GetLowBits(x)));
            }
            else
            {
                // no container exists for this index
                // create a new ArrayContainer, since it will only hold one integer to start
                // get the low order bits and att to the newly created container
                // add the newly created container to the array of containers
                ArrayContainer ac = new ArrayContainer();
                containers.InsertNewKeyValueAt(-containerIndex - 1, highBits, ac.Add(Utility.GetLowBits(x)));
            }
        }
All Usage Examples Of BitsetsNET.RoaringArray::GetIndex