From ac4dbd3b25f022b3ef025f6d3451712187308efb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 15 Oct 2019 14:47:42 -0400 Subject: common: Rename binary_find.h to algorithm.h Makes the header more general for other potential algorithms in the future. While we're at it, include a missing include to satisfy the use of std::less. --- src/common/CMakeLists.txt | 2 +- src/common/algorithm.h | 22 ++++++++++++++++++++++ src/common/binary_find.h | 21 --------------------- src/video_core/texture_cache/surface_base.cpp | 1 + src/video_core/texture_cache/surface_base.h | 5 ++--- 5 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 src/common/algorithm.h delete mode 100644 src/common/binary_find.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 906c486fd..5b51fcafa 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -95,11 +95,11 @@ add_custom_command(OUTPUT scm_rev.cpp ) add_library(common STATIC + algorithm.h alignment.h assert.h detached_tasks.cpp detached_tasks.h - binary_find.h bit_field.h bit_util.h cityhash.cpp diff --git a/src/common/algorithm.h b/src/common/algorithm.h new file mode 100644 index 000000000..18e7ece98 --- /dev/null +++ b/src/common/algorithm.h @@ -0,0 +1,22 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Common { + +template > +ForwardIt BinaryFind(ForwardIt first, ForwardIt last, const T& value, Compare comp = {}) { + // Note: BOTH type T and the type after ForwardIt is dereferenced + // must be implicitly convertible to BOTH Type1 and Type2, used in Compare. + // This is stricter than lower_bound requirement (see above) + + first = std::lower_bound(first, last, value, comp); + return first != last && !comp(value, *first) ? first : last; +} + +} // namespace Common diff --git a/src/common/binary_find.h b/src/common/binary_find.h deleted file mode 100644 index 5cc523bf9..000000000 --- a/src/common/binary_find.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include - -namespace Common { - -template > -ForwardIt BinaryFind(ForwardIt first, ForwardIt last, const T& value, Compare comp = {}) { - // Note: BOTH type T and the type after ForwardIt is dereferenced - // must be implicitly convertible to BOTH Type1 and Type2, used in Compare. - // This is stricter than lower_bound requirement (see above) - - first = std::lower_bound(first, last, value, comp); - return first != last && !comp(value, *first) ? first : last; -} - -} // namespace Common diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp index 683c49207..829268b4c 100644 --- a/src/video_core/texture_cache/surface_base.cpp +++ b/src/video_core/texture_cache/surface_base.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/algorithm.h" #include "common/assert.h" #include "common/common_types.h" #include "common/microprofile.h" diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index 5e497e49f..1bed82898 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h @@ -4,12 +4,11 @@ #pragma once -#include +#include +#include #include #include -#include "common/assert.h" -#include "common/binary_find.h" #include "common/common_types.h" #include "video_core/gpu.h" #include "video_core/morton.h" -- cgit v1.2.3