Add algorithm.mutation.swap
This commit is contained in:
@ -20,9 +20,6 @@ import std.algorithm.mutation : bringToFront,
|
||||
copy,
|
||||
fill,
|
||||
initializeAll,
|
||||
moveEmplaceAll,
|
||||
moveAll,
|
||||
swap,
|
||||
uninitializedFill;
|
||||
import std.meta;
|
||||
import tanya.algorithm.mutation;
|
||||
@ -272,7 +269,10 @@ struct Array(T)
|
||||
{
|
||||
// Move each element.
|
||||
reserve(init.length_);
|
||||
moveEmplaceAll(init.data[0 .. init.length_], this.data[0 .. init.length_]);
|
||||
foreach (ref target; this.data[0 .. init.length_])
|
||||
{
|
||||
moveEmplace(*init.data++, target);
|
||||
}
|
||||
this.length_ = init.length_;
|
||||
// Destructor of init should destroy it here.
|
||||
}
|
||||
@ -661,7 +661,12 @@ struct Array(T)
|
||||
body
|
||||
{
|
||||
auto end = this.data + this.length;
|
||||
moveAll(Range(this, r.end, end), Range(this, r.begin, end));
|
||||
auto source = Range(this, r.end, end);
|
||||
auto target = Range(this, r.begin, end);
|
||||
for (; !source.empty; source.popFront(), target.popFront())
|
||||
{
|
||||
move(source.front, target.front);
|
||||
}
|
||||
length = length - r.length;
|
||||
return Range(this, r.begin, this.data + length);
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
module tanya.container.list;
|
||||
|
||||
import std.algorithm.comparison;
|
||||
import std.algorithm.mutation : swap;
|
||||
import std.algorithm.searching;
|
||||
import tanya.algorithm.mutation;
|
||||
import tanya.container.entry;
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
module tanya.container.set;
|
||||
|
||||
import std.algorithm.mutation : swap;
|
||||
import tanya.algorithm.mutation;
|
||||
import tanya.container;
|
||||
import tanya.container.entry;
|
||||
|
@ -27,7 +27,7 @@
|
||||
module tanya.container.string;
|
||||
|
||||
import std.algorithm.comparison;
|
||||
import std.algorithm.mutation : bringToFront, copy, swap;
|
||||
import std.algorithm.mutation : bringToFront, copy;
|
||||
import std.algorithm.searching;
|
||||
static import std.range;
|
||||
import tanya.algorithm.mutation;
|
||||
|
Reference in New Issue
Block a user