From db846a25067c22b097d637c66c2ffa8fb4c38769 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 4 May 2020 08:51:17 +1000 Subject: Backport: Feature [feature-requests:1347]. Add methods to insert multiple partitions. Backport of changeset 8228:753e94011b20. --- src/Partitioning.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Partitioning.h') diff --git a/src/Partitioning.h b/src/Partitioning.h index bb3320b80..171a694d9 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -124,6 +124,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