Ejemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////////

        public static bool ContainsMajor(long[] array, int size, int value)
        {
            int low  = 0;
            int high = size - 1;

            while (low <= high)
            {
                int midIdx   = low + (high - low) / 2;
                int majorVal = Miscellanea.High(array[midIdx]);

                if (majorVal < value)
                {
                    // midIdx is below the target range
                    low = midIdx + 1;
                }
                else if (majorVal > value)
                {
                    // midIdx is above the target range
                    high = midIdx - 1;
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        //////////////////////////////////////////////////////////////////////////////

        private static void Flip(long[] array, int size)
        {
            for (int i = 0; i < size; i++)
            {
                long entry = array[i];
                array[i] = Miscellanea.Pack(Miscellanea.High(entry), Miscellanea.Low(entry));
            }
        }
Ejemplo n.º 3
0
 private static int Count(long entry)
 {
     return(Miscellanea.High(entry));
 }
Ejemplo n.º 4
0
 static internal int Arg1(long tuple)
 {
     return(Miscellanea.High(tuple));
 }