diff --git a/changelog/std-range-slides.dd b/changelog/std-range-slides.dd deleted file mode 100644 index 1da685325..000000000 --- a/changelog/std-range-slides.dd +++ /dev/null @@ -1,33 +0,0 @@ -`std.range.slide` (a fixed-size sliding window range) was added - -$(REF slide, std, range) allows to iterate a range in sliding windows: - ---- -import std.array : array; -import std.algorithm.comparison : equal; - -assert([0, 1, 2, 3].slide(2).equal!equal( - [[0, 1], [1, 2], [2, 3]] -)); -assert(5.iota.slide(3).equal!equal( - [[0, 1, 2], [1, 2, 3], [2, 3, 4]] -)); - -assert(iota(7).slide(2, 2).equal!equal([[0, 1], [2, 3], [4, 5]])); -assert(iota(12).slide(2, 4).equal!equal([[0, 1], [4, 5], [8, 9]])); - -// set a custom stepsize (default 1) -assert(6.iota.slide(1, 2).equal!equal( - [[0], [2], [4]] -)); - -assert(6.iota.slide(2, 4).equal!equal( - [[0, 1], [4, 5]] -)); - -// allow slide with less elements than the window size -assert(3.iota.slide!(No.withFewerElements)(4).empty); -assert(3.iota.slide!(Yes.withFewerElements)(4).equal!equal( - [[0, 1, 2]] -)); ---- diff --git a/std/range/package.d b/std/range/package.d index 27e1e9c3c..a07b8417e 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -161,12 +161,14 @@ $(BOOKTABLE , $(TD Similar to $(D recurrence), except that a random-access _range is created. )) + $(COMMENT Explicitly undocumented to delay the release until 2.076 $(TR $(TD $(D $(LREF slide))) $(TD Creates a _range that returns a fixed-size sliding window over the original _range. Unlike chunks, it advances a configurable number of items at a time, not one chunk at a time. )) + ) $(TR $(TD $(LREF stride)) $(TD Iterates a _range with stride $(I n). )) @@ -7414,7 +7416,7 @@ if (isForwardRange!Source && hasLength!Source) assert(equal(chunks, [[1], [2], [3], [], []])); } -/** +/* A fixed-sized sliding window iteration of size `windowSize` over a `source` range by a custom `stepSize`. @@ -7438,6 +7440,8 @@ Returns: Range of all sliding windows with propagated bi-directionality, See_Also: $(LREF chunks) */ +// Explicitly set to private to delay the release until 2.076 +private auto slide(Flag!"withFewerElements" f = Yes.withFewerElements, Source)(Source source, size_t windowSize, size_t stepSize = 1) if (isForwardRange!Source) @@ -7812,7 +7816,7 @@ public: } } -/// +// @safe pure nothrow unittest { import std.algorithm.comparison : equal; @@ -7844,7 +7848,7 @@ public: )); } -/// count k-mers +// count k-mers @safe pure nothrow unittest { import std.algorithm.comparison : equal;