Move bisect to Span and deduplicate code.

Co-authored-by: Lukas Tenbrink <lukas.tenbrink@gmail.com>
This commit is contained in:
Yufeng Ying
2025-05-13 22:49:20 +08:00
parent 09fcbb8645
commit 3bf400ffae
9 changed files with 113 additions and 108 deletions

View File

@ -40,7 +40,6 @@
#include "core/error/error_macros.h"
#include "core/templates/cowdata.h"
#include "core/templates/search_array.h"
#include "core/templates/sort_array.h"
#include <initializer_list>
@ -152,8 +151,7 @@ public:
template <typename Comparator, typename Value, typename... Args>
Size bsearch_custom(const Value &p_value, bool p_before, Args &&...args) {
SearchArray<T, Comparator> search{ args... };
return search.bisect(ptrw(), size(), p_value, p_before);
return span().bisect(p_value, p_before, Comparator{ args... });
}
Vector<T> duplicate() {