diff options
author | Zach Hilman <DarkLordZach@users.noreply.github.com> | 2019-07-05 13:39:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-05 13:39:13 -0400 |
commit | 772c86a260eb446b0fe4232b0a50666511bef25c (patch) | |
tree | 013d92268c06454c93565c83eff2b79b56a00839 /src/common/binary_find.h | |
parent | 3f3a93f13b70959b6ba57b22bf8851b5c88929d4 (diff) | |
parent | 3b9d89839dc62e9e63a3cbe9636cf85276babdfb (diff) |
Merge pull request #2601 from FernandoS27/texture_cache
Implement a new Texture Cache
Diffstat (limited to 'src/common/binary_find.h')
-rw-r--r-- | src/common/binary_find.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/binary_find.h b/src/common/binary_find.h new file mode 100644 index 0000000000..5cc523bf9c --- /dev/null +++ b/src/common/binary_find.h @@ -0,0 +1,21 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <algorithm> + +namespace Common { + +template <class ForwardIt, class T, class Compare = std::less<>> +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 |