Fix: Add missing header used by recent backport fix
This was added in main by2cfcb8b0b8, and used by6a05e5161bwhich was cherry-picked from main to the release branch.
This commit is contained in:
38
source/blender/blenlib/BLI_binary_search.hh
Normal file
38
source/blender/blenlib/BLI_binary_search.hh
Normal file
@@ -0,0 +1,38 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
/** \file
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
namespace blender::binary_search {
|
||||
|
||||
/**
|
||||
* Find the index of the first element where the predicate is true. The predicate must also be
|
||||
* true for all following elements. If the predicate is false for all elements, the size of the
|
||||
* range is returned.
|
||||
*/
|
||||
template<typename Iterator, typename Predicate>
|
||||
int64_t find_predicate_begin(Iterator begin, Iterator end, Predicate &&predicate)
|
||||
{
|
||||
return std::lower_bound(begin,
|
||||
end,
|
||||
nullptr,
|
||||
[&](const auto &value, void * /*dummy*/) { return !predicate(value); }) -
|
||||
begin;
|
||||
}
|
||||
|
||||
template<typename Range, typename Predicate>
|
||||
int64_t find_predicate_begin(const Range &range, Predicate &&predicate)
|
||||
{
|
||||
return find_predicate_begin(range.begin(), range.end(), predicate);
|
||||
}
|
||||
|
||||
} // namespace blender::binary_search
|
||||
@@ -182,6 +182,7 @@ set(SRC
|
||||
BLI_assert.h
|
||||
BLI_astar.h
|
||||
BLI_atomic_disjoint_set.hh
|
||||
BLI_binary_search.hh
|
||||
BLI_bit_group_vector.hh
|
||||
BLI_bit_ref.hh
|
||||
BLI_bit_span.hh
|
||||
|
||||
Reference in New Issue
Block a user