Remove code deprecated in 0.11.2 and earlier
- conv.to!String - meta.metafunction.Tuple - range.adapter.take - range.adapter.takeExactly - range.primitive: put()-ting input range into an output one
This commit is contained in:
parent
c5eb2f27be
commit
e68fcc3a38
@ -856,13 +856,6 @@ if (is(Unqual!From == bool) && isNumeric!To && !is(Unqual!To == Unqual!From))
|
|||||||
assert(false.to!int == 0);
|
assert(false.to!int == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
deprecated("Use tanya.format.format instead")
|
|
||||||
To to(To, From)(auto ref From from)
|
|
||||||
if (is(Unqual!To == String))
|
|
||||||
{
|
|
||||||
return format!"{}"(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a stringish range to an integral value.
|
* Converts a stringish range to an integral value.
|
||||||
*
|
*
|
||||||
|
@ -238,18 +238,6 @@ struct Pack(Args...)
|
|||||||
alias Seq this;
|
alias Seq this;
|
||||||
}
|
}
|
||||||
|
|
||||||
deprecated("Use Pack instead")
|
|
||||||
struct Tuple(Args...)
|
|
||||||
{
|
|
||||||
/// Elements in this tuple as $(D_PSYMBOL AliasSeq).
|
|
||||||
alias Seq = Args;
|
|
||||||
|
|
||||||
/// The length of the tuple.
|
|
||||||
enum size_t length = Args.length;
|
|
||||||
|
|
||||||
alias Seq this;
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@nogc nothrow pure @safe unittest
|
@nogc nothrow pure @safe unittest
|
||||||
{
|
{
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
/**
|
/**
|
||||||
* Range adapters.
|
* Range adapters.
|
||||||
*
|
*
|
||||||
* A range adapter wraps another range and modifies the way, how the original
|
|
||||||
* range is iterated, or the order in which its elements are accessed.
|
|
||||||
*
|
|
||||||
* All adapters are lazy algorithms, they request the next element of the
|
|
||||||
* adapted range on demand.
|
|
||||||
*
|
|
||||||
* Copyright: Eugene Wissner 2018.
|
* Copyright: Eugene Wissner 2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
@ -18,245 +12,4 @@
|
|||||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/range/adapter.d,
|
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/range/adapter.d,
|
||||||
* tanya/range/adapter.d)
|
* tanya/range/adapter.d)
|
||||||
*/
|
*/
|
||||||
deprecated("Use tanya.algorithm.iteration instead")
|
|
||||||
module tanya.range.adapter;
|
module tanya.range.adapter;
|
||||||
|
|
||||||
import tanya.algorithm.mutation;
|
|
||||||
import tanya.math;
|
|
||||||
import tanya.range.primitive;
|
|
||||||
|
|
||||||
private mixin template Take(R, bool exactly)
|
|
||||||
{
|
|
||||||
private R source;
|
|
||||||
size_t length_;
|
|
||||||
|
|
||||||
@disable this();
|
|
||||||
|
|
||||||
private this(R source, size_t length)
|
|
||||||
{
|
|
||||||
this.source = source;
|
|
||||||
static if (!exactly && hasLength!R)
|
|
||||||
{
|
|
||||||
this.length_ = min(source.length, length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.length_ = length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@property auto ref front()
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
return this.source.front;
|
|
||||||
}
|
|
||||||
|
|
||||||
void popFront()
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
this.source.popFront();
|
|
||||||
--this.length_;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property bool empty()
|
|
||||||
{
|
|
||||||
static if (exactly || isInfinite!R)
|
|
||||||
{
|
|
||||||
return length == 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return length == 0 || this.source.empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@property size_t length()
|
|
||||||
{
|
|
||||||
return this.length_;
|
|
||||||
}
|
|
||||||
|
|
||||||
static if (hasAssignableElements!R)
|
|
||||||
{
|
|
||||||
@property void front(ref ElementType!R value)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
this.source.front = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property void front(ElementType!R value)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
this.source.front = move(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static if (isForwardRange!R)
|
|
||||||
{
|
|
||||||
typeof(this) save()
|
|
||||||
{
|
|
||||||
return typeof(this)(this.source.save(), length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static if (isRandomAccessRange!R)
|
|
||||||
{
|
|
||||||
@property auto ref back()
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
return this.source[this.length - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
void popBack()
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
--this.length_;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ref opIndex(size_t i)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(i < length);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
return this.source[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static if (hasAssignableElements!R)
|
|
||||||
{
|
|
||||||
@property void back(ref ElementType!R value)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
this.source[length - 1] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property void back(ElementType!R value)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(!empty);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
this.source[length - 1] = move(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void opIndexAssign(ref ElementType!R value, size_t i)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(i < length);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
this.source[i] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void opIndexAssign(ElementType!R value, size_t i)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(i < length);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
this.source[i] = move(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static if (hasSlicing!R)
|
|
||||||
{
|
|
||||||
auto opSlice(size_t i, size_t j)
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(i <= j);
|
|
||||||
assert(j <= length);
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
return take(this.source[i .. j], length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes $(D_PARAM n) elements from $(D_PARAM range).
|
|
||||||
*
|
|
||||||
* If $(D_PARAM range) doesn't have $(D_PARAM n) elements, the resulting range
|
|
||||||
* spans all elements of $(D_PARAM range).
|
|
||||||
*
|
|
||||||
* $(D_PSYMBOL take) is particulary useful with infinite ranges. You can take
|
|
||||||
` $(B n) elements from such range and pass the result to an algorithm which
|
|
||||||
* expects a finit range.
|
|
||||||
*
|
|
||||||
* Params:
|
|
||||||
* R = Type of the adapted range.
|
|
||||||
* range = The range to take the elements from.
|
|
||||||
* n = The number of elements to take.
|
|
||||||
*
|
|
||||||
* Returns: A range containing maximum $(D_PARAM n) first elements of
|
|
||||||
* $(D_PARAM range).
|
|
||||||
*
|
|
||||||
* See_Also: $(D_PSYMBOL takeExactly).
|
|
||||||
*/
|
|
||||||
auto take(R)(R range, size_t n)
|
|
||||||
if (isInputRange!R)
|
|
||||||
{
|
|
||||||
struct Take
|
|
||||||
{
|
|
||||||
mixin .Take!(R, false);
|
|
||||||
}
|
|
||||||
return Take(range, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes exactly $(D_PARAM n) elements from $(D_PARAM range).
|
|
||||||
*
|
|
||||||
* $(D_PARAM range) must have at least $(D_PARAM n) elements.
|
|
||||||
*
|
|
||||||
* $(D_PSYMBOL takeExactly) is particulary useful with infinite ranges. You can
|
|
||||||
` take $(B n) elements from such range and pass the result to an algorithm
|
|
||||||
* which expects a finit range.
|
|
||||||
*
|
|
||||||
* Params:
|
|
||||||
* R = Type of the adapted range.
|
|
||||||
* range = The range to take the elements from.
|
|
||||||
* n = The number of elements to take.
|
|
||||||
*
|
|
||||||
* Returns: A range containing $(D_PARAM n) first elements of $(D_PARAM range).
|
|
||||||
*
|
|
||||||
* See_Also: $(D_PSYMBOL take).
|
|
||||||
*/
|
|
||||||
auto takeExactly(R)(R range, size_t n)
|
|
||||||
if (isInputRange!R)
|
|
||||||
{
|
|
||||||
struct TakeExactly
|
|
||||||
{
|
|
||||||
mixin Take!(R, true);
|
|
||||||
}
|
|
||||||
return TakeExactly(range, n);
|
|
||||||
}
|
|
||||||
|
@ -813,16 +813,27 @@ template isRandomAccessRange(R)
|
|||||||
/**
|
/**
|
||||||
* Puts $(D_PARAM e) into the $(D_PARAM range).
|
* Puts $(D_PARAM e) into the $(D_PARAM range).
|
||||||
*
|
*
|
||||||
* $(D_PSYMBOL R) should be an output range for $(D_PARAM E).
|
* $(D_PSYMBOL R) should be an output range for $(D_PARAM E). It doesn't mean
|
||||||
*
|
* that everything $(D_PARAM range) is an output range for can be put into it,
|
||||||
* $(D_PARAM range) is advanced after putting an element into it if all of the
|
* but only if one of the following conditions is met:
|
||||||
* following conditions are met:
|
|
||||||
*
|
*
|
||||||
* $(OL
|
* $(OL
|
||||||
* $(LI $(D_PSYMBOL R) is an input range)
|
* $(LI $(D_PARAM R) defines a `put`-method for $(D_PARAM E))
|
||||||
* $(LI $(D_PSYMBOL R) doesn't define a `put`-method)
|
|
||||||
* $(LI $(D_PARAM e) can be assigned to $(D_INLINECODE range.front))
|
* $(LI $(D_PARAM e) can be assigned to $(D_INLINECODE range.front))
|
||||||
|
* $(LI $(D_PARAM e) can be put into $(D_PARAM range) using
|
||||||
|
* $(D_INLINECODE range(e))
|
||||||
* )
|
* )
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* The method to put $(D_PARAM e) into $(D_PARAM range) is chosen based on the
|
||||||
|
* order specified above.
|
||||||
|
*
|
||||||
|
* If $(D_PARAM E) is an input range and $(D_PARAM R) is an output range for
|
||||||
|
* its elements as well, use $(D_PSYMBOL tanya.algorithm.mutation.copy)
|
||||||
|
* instead.
|
||||||
|
*
|
||||||
|
* $(D_PARAM range) is advanced after putting an element into it if it is an
|
||||||
|
* input range that doesn't define a `put`-method.
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* R = Target range type.
|
* R = Target range type.
|
||||||
@ -849,15 +860,6 @@ void put(R, E)(ref R range, auto ref E e)
|
|||||||
{
|
{
|
||||||
range(e);
|
range(e);
|
||||||
}
|
}
|
||||||
else static if (isInputRange!E)
|
|
||||||
{
|
|
||||||
pragma(msg, "Putting an input range into an output range is "
|
|
||||||
~ "deprecated. Use tanya.algorithm.mutation.copy instead");
|
|
||||||
for (; !e.empty; e.popFront())
|
|
||||||
{
|
|
||||||
put(range, e.front);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static assert(false, R.stringof ~ " is not an output range for "
|
static assert(false, R.stringof ~ " is not an output range for "
|
||||||
|
Loading…
Reference in New Issue
Block a user