算法模块上传
@@ -0,0 +1,14 @@
+//cmp(compare function):from front to rear
+template<typename _T>
+int BinarySearchInc(_T* x, _T target, bool* cmp(_T, _T), int start = 0, int end) {
+ int L = start, R = end, M, res = -1;
+ while (L <= R) {
+ M = (L + R) >> 1;
+ if (cmp(x[M], target))
+ res = M,
+ R = M - 1;
+ else
+ L = M + 1;
+ }
+ return res;
+}