diff options
Diffstat (limited to 'src/Partitioning.h')
| -rw-r--r-- | src/Partitioning.h | 50 | 
1 files changed, 25 insertions, 25 deletions
diff --git a/src/Partitioning.h b/src/Partitioning.h index da68dfb56..358fbd028 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -24,8 +24,8 @@ public:  	// Deleted so SplitVectorWithRangeAdd objects can not be copied.  	SplitVectorWithRangeAdd(const SplitVectorWithRangeAdd &) = delete;  	SplitVectorWithRangeAdd(SplitVectorWithRangeAdd &&) = delete; -	void operator=(const SplitVectorWithRangeAdd &) = delete; -	void operator=(SplitVectorWithRangeAdd &&) = delete; +	SplitVectorWithRangeAdd &operator=(const SplitVectorWithRangeAdd &) = delete; +	SplitVectorWithRangeAdd &operator=(SplitVectorWithRangeAdd &&) = default;  	~SplitVectorWithRangeAdd() {  	}  	void RangeAddDelta(T start, T end, T delta) noexcept { @@ -63,12 +63,12 @@ private:  	// there may be a step somewhere in the list.  	T stepPartition;  	T stepLength; -	std::unique_ptr<SplitVectorWithRangeAdd<T>> body; +	SplitVectorWithRangeAdd<T> body;  	// Move step forward  	void ApplyStep(T partitionUpTo) noexcept {  		if (stepLength != 0) { -			body->RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength); +			body.RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength);  		}  		stepPartition = partitionUpTo;  		if (stepPartition >= Partitions()) { @@ -80,17 +80,17 @@ private:  	// Move step backward  	void BackStep(T partitionDownTo) noexcept {  		if (stepLength != 0) { -			body->RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength); +			body.RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength);  		}  		stepPartition = partitionDownTo;  	}  	void Allocate(ptrdiff_t growSize) { -		body = std::make_unique<SplitVectorWithRangeAdd<T>>(growSize); +		body = SplitVectorWithRangeAdd<T>(growSize);  		stepPartition = 0;  		stepLength = 0; -		body->Insert(0, 0);	// This value stays 0 for ever -		body->Insert(1, 0);	// This is the end of the first partition and will be the start of the second +		body.Insert(0, 0);	// This value stays 0 for ever +		body.Insert(1, 0);	// This is the end of the first partition and will be the start of the second  	}  public: @@ -101,19 +101,19 @@ public:  	// Deleted so Partitioning objects can not be copied.  	Partitioning(const Partitioning &) = delete;  	Partitioning(Partitioning &&) = delete; -	void operator=(const Partitioning &) = delete; -	void operator=(Partitioning &&) = delete; +	Partitioning &operator=(const Partitioning &) = delete; +	Partitioning &operator=(Partitioning &&) = default;  	~Partitioning() {  	}  	T Partitions() const noexcept { -		return static_cast<T>(body->Length())-1; +		return static_cast<T>(body.Length())-1;  	}  	void ReAllocate(ptrdiff_t newSize) {  		// + 1 accounts for initial element that is always 0. -		body->ReAllocate(newSize + 1); +		body.ReAllocate(newSize + 1);  	}  	T Length() const noexcept { @@ -124,7 +124,7 @@ public:  		if (stepPartition < partition) {  			ApplyStep(partition);  		} -		body->Insert(partition, pos); +		body.Insert(partition, pos);  		stepPartition++;  	} @@ -132,7 +132,7 @@ public:  		if (stepPartition < partition) {  			ApplyStep(partition);  		} -		body->InsertFromArray(partition, positions, 0, length); +		body.InsertFromArray(partition, positions, 0, length);  		stepPartition += static_cast<T>(length);  	} @@ -141,7 +141,7 @@ public:  		if (stepPartition < partition) {  			ApplyStep(partition);  		} -		T *pInsertion = body->InsertEmpty(partition, length); +		T *pInsertion = body.InsertEmpty(partition, length);  		for (size_t i = 0; i < length; i++) {  			pInsertion[i] = static_cast<T>(positions[i]);  		} @@ -150,10 +150,10 @@ public:  	void SetPartitionStartPosition(T partition, T pos) noexcept {  		ApplyStep(partition+1); -		if ((partition < 0) || (partition >= body->Length())) { +		if ((partition < 0) || (partition >= body.Length())) {  			return;  		} -		body->SetValueAt(partition, pos); +		body.SetValueAt(partition, pos);  	}  	void InsertText(T partitionInsert, T delta) noexcept { @@ -163,7 +163,7 @@ public:  				// Fill in up to the new insertion point  				ApplyStep(partitionInsert);  				stepLength += delta; -			} else if (partitionInsert >= (stepPartition - body->Length() / 10)) { +			} else if (partitionInsert >= (stepPartition - body.Length() / 10)) {  				// Close to step but before so move step back  				BackStep(partitionInsert);  				stepLength += delta; @@ -185,17 +185,17 @@ public:  		} else {  			stepPartition--;  		} -		body->Delete(partition); +		body.Delete(partition);  	}  	T PositionFromPartition(T partition) const noexcept {  		PLATFORM_ASSERT(partition >= 0); -		PLATFORM_ASSERT(partition < body->Length()); -		const ptrdiff_t lengthBody = body->Length(); +		PLATFORM_ASSERT(partition < body.Length()); +		const ptrdiff_t lengthBody = body.Length();  		if ((partition < 0) || (partition >= lengthBody)) {  			return 0;  		} -		T pos = body->ValueAt(partition); +		T pos = body.ValueAt(partition);  		if (partition > stepPartition)  			pos += stepLength;  		return pos; @@ -203,7 +203,7 @@ public:  	/// Return value in range [0 .. Partitions() - 1] even for arguments outside interval  	T PartitionFromPosition(T pos) const noexcept { -		if (body->Length() <= 1) +		if (body.Length() <= 1)  			return 0;  		if (pos >= (PositionFromPartition(Partitions())))  			return Partitions() - 1; @@ -211,7 +211,7 @@ public:  		T upper = Partitions();  		do {  			const T middle = (upper + lower + 1) / 2; 	// Round high -			T posMiddle = body->ValueAt(middle); +			T posMiddle = body.ValueAt(middle);  			if (middle > stepPartition)  				posMiddle += stepLength;  			if (pos < posMiddle) { @@ -224,7 +224,7 @@ public:  	}  	void DeleteAll() { -		Allocate(body->GetGrowSize()); +		Allocate(body.GetGrowSize());  	}  	void Check() const {  | 
