标签:查询 isp sum name ddl class returns splay gif
1 /// <summary> 2 /// 二分法查询值所在位置 3 /// </summary> 4 /// <param name="value">要查询的值</param> 5 /// <returns>值所在索引</returns> 6 private static int SearchIndex(long value) 7 { 8 int Index = -1; 9 int low = 0; 10 int high = Data.Count - 1; 11 12 while (low <= high) 13 { 14 int middle = (low + high) >> 1; 15 long temp = Data[middle]; 16 17 if (temp == value) 18 { 19 Index = middle; 20 return Index; 21 } 22 if (temp > value) 23 { 24 high = middle - 1; 25 } 26 else 27 { 28 low = middle + 1; 29 } 30 } 31 return Index; 32 }
标签:查询 isp sum name ddl class returns splay gif
原文地址:http://www.cnblogs.com/BeInNight/p/6761716.html