Example #1
0
        public static CPointer <TVal> bsearch <TKey, TVal>(TKey key, CPointer <TVal> array, int n, Func <TKey, TVal, int> compare)
        {
            var list = new List <TVal>(array.ToArray().Take(n));
            var idx  = list.BinarySearch(default(TVal), new bcomparer <TKey, TVal>(key, compare));

            return(idx >= 0 ? array + idx : new CPointer <TVal>());
        }
Example #2
0
        public static void qsort <T>(CPointer <T> array, int n, Comparison <T> compare)
        {
            var list = new List <T>(array.ToArray().Take(n));

            list.Sort(compare);
            for (int i = 0; i < list.Count; i++)
            {
                array[i] = list[i];
            }
        }