Beispiel #1
0
        internal static int Bisect(List <EdgeKey> list, EdgeKey item)
        {
            int lo = 0, hi = list.Count;

            while (lo < hi)
            {
                int mid = (lo + hi) / 2;
                if (item < list[mid])
                {
                    hi = mid;
                }
                else
                {
                    lo = mid + 1;
                }
            }
            return(lo);
        }
Beispiel #2
0
        internal static List <EdgeKey> AddItemSorted(List <EdgeKey> list, EdgeKey item)
        {
            int lo = 0;
            int hi = list.Count();

            while (lo < hi)
            {
                int mid = (int)(lo + hi) / 2;
                if (item < list[mid])
                {
                    hi = mid;
                }
                else
                {
                    lo = mid + 1;
                }
            }
            list.Insert(lo, item);

            return(list);
        }