A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.
This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.
Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.
Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:
https://reuse.software/faq/
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
/* 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
|