Add algorithm.mutation.rotate

This commit is contained in:
2018-11-12 07:54:52 +01:00
parent 3f66782368
commit 9e6f5c3105
3 changed files with 95 additions and 11 deletions

View File

@@ -26,7 +26,6 @@
*/
module tanya.container.string;
import std.algorithm.mutation : bringToFront;
import tanya.algorithm.comparison;
import tanya.algorithm.mutation;
import tanya.hash.lookup;
@@ -1531,11 +1530,10 @@ struct String
do
{
const oldLength = length;
const rangeEnd = r.end - this.data;
const after = r.end - this.data;
const inserted = insertBack(el);
auto containerEnd = this.data + oldLength;
bringToFront(ByCodeUnit!char(this, this.data + rangeEnd, containerEnd),
ByCodeUnit!char(this, containerEnd, this.data + length));
rotate(this.data[after .. oldLength], this.data[oldLength .. length]);
return inserted;
}