コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public object GetValueByKey(object key)
        {
            var hashdKey = key.GetHashCode();
            var id       = BSearch.BinarySearch(keys, hashdKey);

            return(id != -1 ? values[id] : null);
        }
コード例 #3
0
 public static bool BinarySearchTest(int[] arr, int search)
 {
     return(BSearch.BinarySearch(arr, search));
 }
コード例 #4
0
 public static bool BinarySearchTest(long[] arr, long search)
 {
     return(BSearch.BinarySearch(arr, search));
 }
コード例 #5
0
 public static bool BinarySearchTest(byte[] arr, byte search)
 {
     return(BSearch.BinarySearch(arr, search));
 }
コード例 #6
0
 public static bool BinarySearchTest(double[] arr, double search)
 {
     return(BSearch.BinarySearch(arr, search));
 }