From 5e5d17b0f5d97be4c11a96a2ad2c8e10a6127832 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Sun, 7 Aug 2022 03:06:29 +0800 Subject: feat: Implement expt_0804 Signed-off-by: KunoiSayami --- expt_0802.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'expt_0802.cpp') diff --git a/expt_0802.cpp b/expt_0802.cpp index fbd6c23..b1a906a 100644 --- a/expt_0802.cpp +++ b/expt_0802.cpp @@ -25,8 +25,6 @@ size_t calculate_location(size_t index) { } typedef int key_type; -inline double safeStep(double step) { return step < 0 ? 0 : step; } - int get_son_from_step(int point, bool negative) { return negative ? point * 2 : point * 2 + 1; } @@ -34,31 +32,18 @@ int get_son_from_step(int point, bool negative) { const key_type *cudaBinarySearch(key_type *const start, const key_type *end, const key_type val) { int step_limit = (int)std::log2(LENGTH) + 1; - const auto length = (end - start); key_type *last_known_point = start; auto son = 0; for (int i = 0; i < step_limit; i++) { const auto next_level_start = start + (1 << (i + 1)) - 1; - /*const auto current_time = (1.0 / (1 << (i + 1))); - printf("%d ", *level_start); - printf("%d %d\n", *last_known_point, (1 << i)); if (*last_known_point == val) { - puts("find"); - return last_known_point; - } - sum = safeStep(sum + - ((*last_known_point > val) ? -current_time : current_time)); - last_known_point = level_start + (int)(sum * (double)(1 << i));*/ - if (*last_known_point == val) { - puts("found"); return last_known_point; } son = get_son_from_step(son, (*last_known_point > val)); last_known_point = next_level_start + son; printf("%d\n", *last_known_point); } - puts(""); return last_known_point; } -- cgit v1.3.1