summaryrefslogtreecommitdiff
path: root/gfx/gl/instanceVertices.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2026-02-14 20:13:10 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2026-02-14 20:13:10 +0000
commitb4d95c3842577e0fcb71e2d3e4adda7c82a661ba (patch)
treeb1205ce06f659751f50e8a6e52adea399b593bfb /gfx/gl/instanceVertices.h
parentReturn indices instead of iterates from InstanceVertices::partition (diff)
downloadilt-b4d95c3842577e0fcb71e2d3e4adda7c82a661ba.tar.bz2
ilt-b4d95c3842577e0fcb71e2d3e4adda7c82a661ba.tar.xz
ilt-b4d95c3842577e0fcb71e2d3e4adda7c82a661ba.zip
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.
Diffstat (limited to 'gfx/gl/instanceVertices.h')
-rw-r--r--gfx/gl/instanceVertices.h14
1 files changed, 14 insertions, 0 deletions
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 <cassert>
+#include <functional>
#include <special_members.h>
#include <utility>
@@ -133,6 +134,19 @@ public:
return indexOf(partition(base::begin(), base::end(), pred));
}
+ using PartitionResult
+ = std::pair<typename base::size_type, std::pair<typename base::size_type, typename base::size_type>>;
+
+ template<typename Pred1, typename Pred2>
+ 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<size_t>(-1);
friend InstanceProxy;