From 2175e34a7449f59ee6f9fa2466cbe13b6a92232e Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 4 May 2020 08:51:17 +1000 Subject: Feature [feature-requests:1347]. Add methods to insert multiple partitions. --- src/Partitioning.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/Partitioning.h b/src/Partitioning.h index 11c64bc83..195daae9b 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -122,6 +122,26 @@ public: stepPartition++; } + void InsertPartitions(T partition, const T *positions, size_t length) { + if (stepPartition < partition) { + ApplyStep(partition); + } + body->InsertFromArray(partition, positions, 0, length); + stepPartition += static_cast(length); + } + + void InsertPartitionsWithCast(T partition, const ptrdiff_t *positions, size_t length) { + // Used for 64-bit builds when T is 32-bits + if (stepPartition < partition) { + ApplyStep(partition); + } + T *pInsertion = body->InsertEmpty(partition, length); + for (size_t i = 0; i < length; i++) { + pInsertion[i] = static_cast(positions[i]); + } + stepPartition += static_cast(length); + } + void SetPartitionStartPosition(T partition, T pos) noexcept { ApplyStep(partition+1); if ((partition < 0) || (partition > body->Length())) { -- cgit v1.2.3