示例#1
0
        public static void Main()
        {
            BinarySearchFindFirstLastOccurenceProcessor processor = new BinarySearchFindFirstLastOccurenceProcessor();

            processor.Process();
            Console.ReadKey();
        }
        private int CountOccurence(int[] array, int itemToBeSearched)
        {
            BinarySearchFindFirstLastOccurenceProcessor firstLastOccurence = new BinarySearchFindFirstLastOccurenceProcessor();

            int firstOccurence = firstLastOccurence.FindFirstOrLastOccurence(array, itemToBeSearched, true);
            int lastOccurence  = firstLastOccurence.FindFirstOrLastOccurence(array, itemToBeSearched, false);

            return(lastOccurence - firstOccurence + 1);
        }