给一个严格递增数列,函数int Search_Bin(SSTable T, KeyType k)用来二分地查找k在数列中的位置。
int Search_Bin(SSTable T, KeyType k)
{
int left=1, mid, right;
right = T.length;
mid = (left + right)/2;
while ( left<=right ) {
if ( T.R[mid].key > k ) {
right = mid - 1;
mid = (left + right)/2;
} else if ( T.R[mid].key < k ) {
left = mid + 1;
mid = (left + right)/2;
} else {
return mid;
}
}
return 0;
}