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); }
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); }