public void PutPair(object key, object value) { var hashdKey = key.GetHashCode(); int id; if ((id = BSearch.BinarySearch(keys, hashdKey)) != -1) { values[id] = value; } else if (num < Length) { keys[num] = hashdKey; values[num] = value; num++; } else { Console.WriteLine("(!) Переполнение таблицы. err: a[{0}] = {1}", key, value); return; } if (!QSort.IsSortedArray(keys)) { QSort.QuickSortAssociative(keys, values); } }
public object GetValueByKey(object key) { var hashdKey = key.GetHashCode(); var id = BSearch.BinarySearch(keys, hashdKey); return(id != -1 ? values[id] : null); }
public static bool BinarySearchTest(int[] arr, int search) { return(BSearch.BinarySearch(arr, search)); }
public static bool BinarySearchTest(long[] arr, long search) { return(BSearch.BinarySearch(arr, search)); }
public static bool BinarySearchTest(byte[] arr, byte search) { return(BSearch.BinarySearch(arr, search)); }
public static bool BinarySearchTest(double[] arr, double search) { return(BSearch.BinarySearch(arr, search)); }