From b4d95c3842577e0fcb71e2d3e4adda7c82a661ba Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 14 Feb 2026 20:13:10 +0000 Subject: Add support for partitioning by 2 unary predicates Second predicate creates a single block of truthy values in the middle, and two falsy blocks at each end. --- gfx/gl/instanceVertices.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gfx') diff --git a/gfx/gl/instanceVertices.h b/gfx/gl/instanceVertices.h index 629c664..de20871 100644 --- a/gfx/gl/instanceVertices.h +++ b/gfx/gl/instanceVertices.h @@ -2,6 +2,7 @@ #include "glContainer.h" #include +#include #include #include @@ -133,6 +134,19 @@ public: return indexOf(partition(base::begin(), base::end(), pred)); } + using PartitionResult + = std::pair>; + + template + PartitionResult + partition(Pred1 pred1, Pred2 pred2) + { + auto boundary1 = partition(base::begin(), base::end(), pred1); + auto begin2 = partition(base::begin(), boundary1, std::not_fn(pred2)); + auto end2 = partition(boundary1, base::end(), pred2); + return {indexOf(boundary1), {indexOf(begin2), indexOf(end2)}}; + } + protected: static constexpr auto npos = static_cast(-1); friend InstanceProxy; -- cgit v1.3