Remove std::function usage from ArrayExtensions

This commit is contained in:
Wojtek Figat
2023-10-02 12:52:44 +02:00
parent 41f005f95b
commit 8bafdb0b78
6 changed files with 11 additions and 13 deletions

View File

@@ -4,7 +4,7 @@
#include "../Collections/Array.h"
#include "../Collections/Dictionary.h"
#include <functional>
#include "../Delegate.h"
class ArrayExtensions;
@@ -23,7 +23,6 @@ public:
/// <summary>
/// Gets the common key.
/// </summary>
/// <returns>The key.</returns>
FORCE_INLINE const TKey& GetKey() const
{
return _key;
@@ -32,7 +31,6 @@ public:
/// <summary>
/// Gets the common key.
/// </summary>
/// <returns>The key.</returns>
FORCE_INLINE TKey GetKey()
{
return _key;
@@ -52,7 +50,7 @@ public:
/// <param name="predicate">The prediction function. Should return true for the target element to find.</param>
/// <returns>The index of the element or -1 if nothing found.</returns>
template<typename T, typename AllocationType>
static int32 IndexOf(const Array<T, AllocationType>& obj, const std::function<bool(const T&)>& predicate)
static int32 IndexOf(const Array<T, AllocationType>& obj, const Function<bool(const T&)>& predicate)
{
for (int32 i = 0; i < obj.Count(); i++)
{
@@ -71,7 +69,7 @@ public:
/// <param name="predicate">The prediction function.</param>
/// <returns>True if any element in the collection matches the prediction, otherwise false.</returns>
template<typename T, typename AllocationType>
static bool Any(const Array<T, AllocationType>& obj, const std::function<bool(const T&)>& predicate)
static bool Any(const Array<T, AllocationType>& obj, const Function<bool(const T&)>& predicate)
{
for (int32 i = 0; i < obj.Count(); i++)
{
@@ -90,7 +88,7 @@ public:
/// <param name="predicate">The prediction function.</param>
/// <returns>True if all elements in the collection matches the prediction, otherwise false.</returns>
template<typename T, typename AllocationType>
static int32 All(const Array<T, AllocationType>& obj, const std::function<bool(const T&)>& predicate)
static int32 All(const Array<T, AllocationType>& obj, const Function<bool(const T&)>& predicate)
{
for (int32 i = 0; i < obj.Count(); i++)
{
@@ -109,7 +107,7 @@ public:
/// <param name="keySelector">A function to extract the key for each element.</param>
/// <param name="result">The result collection with groups.</param>
template<typename TSource, typename TKey, typename AllocationType>
static void GroupBy(const Array<TSource, AllocationType>& obj, const std::function<TKey(TSource const&)>& keySelector, Array<IGrouping<TKey, TSource>, AllocationType>& result)
static void GroupBy(const Array<TSource, AllocationType>& obj, const Function<TKey(TSource const&)>& keySelector, Array<IGrouping<TKey, TSource>, AllocationType>& result)
{
Dictionary<TKey, IGrouping<TKey, TSource>> data(static_cast<int32>(obj.Count() * 3.0f));
for (int32 i = 0; i < obj.Count(); i++)

View File

@@ -130,7 +130,7 @@ void FoliageType::Serialize(SerializeStream& stream, const void* otherObj)
SERIALIZE(Model);
const std::function<bool(const ModelInstanceEntry&)> IsValidMaterial = [](const ModelInstanceEntry& e) -> bool
const Function<bool(const ModelInstanceEntry&)> IsValidMaterial = [](const ModelInstanceEntry& e) -> bool
{
return e.Material;
};

View File

@@ -66,7 +66,7 @@ public:
const auto parentModelIndex = node.ParentIndex;
// Find matching node in skeleton (or map to best parent)
const std::function<bool(const T&)> f = [node](const T& x) -> bool
const Function<bool(const T&)> f = [node](const T& x) -> bool
{
return x.Name == node.Name;
};

View File

@@ -578,7 +578,7 @@ void GPUDeviceVulkan::ParseOptionalDeviceExtensions(const Array<const char*>& de
const auto HasExtension = [&deviceExtensions](const char* name) -> bool
{
const std::function<bool(const char* const&)> CheckCallback = [&name](const char* const& extension) -> bool
const Function<bool(const char* const&)> CheckCallback = [&name](const char* const& extension) -> bool
{
return StringUtils::Compare(extension, name) == 0;
};

View File

@@ -431,7 +431,7 @@ void DeferredDeletionQueueVulkan::EnqueueGenericResource(Type type, uint64 handl
ScopeLock lock(_locker);
#if BUILD_DEBUG
const std::function<bool(const Entry&)> ContainsHandle = [handle](const Entry& e)
const Function<bool(const Entry&)> ContainsHandle = [handle](const Entry& e)
{
return e.Handle == handle;
};
@@ -1087,7 +1087,7 @@ GPUDevice* GPUDeviceVulkan::Create()
const auto hasExtension = [](const Array<const char*>& extensions, const char* name) -> bool
{
const std::function<bool(const char* const&)> callback = [&name](const char* const& extension) -> bool
const Function<bool(const char* const&)> callback = [&name](const char* const& extension) -> bool
{
return extension && StringUtils::Compare(extension, name) == 0;
};

View File

@@ -1474,7 +1474,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
// Group meshes that can be merged together
typedef Pair<int32, int32> MeshGroupKey;
const std::function<MeshGroupKey(MeshData* const&)> f = [](MeshData* const& x) -> MeshGroupKey
const Function<MeshGroupKey(MeshData* const&)> f = [](MeshData* const& x) -> MeshGroupKey
{
return MeshGroupKey(x->NodeIndex, x->MaterialSlotIndex);
};