mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 00:20:26 +03:00
Delete commented-out dead code.
Has been dead since 2009.
This commit is contained in:
parent
8814b27d8d
commit
3fb23fa606
1 changed files with 0 additions and 135 deletions
|
@ -299,141 +299,6 @@ template forward(args...)
|
||||||
auto x2 = bar(value); // case of OK
|
auto x2 = bar(value); // case of OK
|
||||||
}
|
}
|
||||||
|
|
||||||
// overwriteAdjacent
|
|
||||||
/*
|
|
||||||
Reduces $(D r) by shifting it to the left until no adjacent elements
|
|
||||||
$(D a), $(D b) remain in $(D r) such that $(D pred(a, b)). Shifting is
|
|
||||||
performed by evaluating $(D move(source, target)) as a primitive. The
|
|
||||||
algorithm is stable and runs in $(BIGOH r.length) time. Returns the
|
|
||||||
reduced range.
|
|
||||||
|
|
||||||
The default $(XREF _algorithm, move) performs a potentially
|
|
||||||
destructive assignment of $(D source) to $(D target), so the objects
|
|
||||||
beyond the returned range should be considered "empty". By default $(D
|
|
||||||
pred) compares for equality, in which case $(D overwriteAdjacent)
|
|
||||||
collapses adjacent duplicate elements to one (functionality akin to
|
|
||||||
the $(WEB wikipedia.org/wiki/Uniq, uniq) system utility).
|
|
||||||
|
|
||||||
Example:
|
|
||||||
----
|
|
||||||
int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ];
|
|
||||||
auto r = overwriteAdjacent(arr);
|
|
||||||
assert(r == [ 1, 2, 3, 4, 5 ]);
|
|
||||||
----
|
|
||||||
*/
|
|
||||||
// Range overwriteAdjacent(alias pred, alias move, Range)(Range r)
|
|
||||||
// {
|
|
||||||
// if (r.empty) return r;
|
|
||||||
// //auto target = begin(r), e = end(r);
|
|
||||||
// auto target = r;
|
|
||||||
// auto source = r;
|
|
||||||
// source.popFront();
|
|
||||||
// while (!source.empty)
|
|
||||||
// {
|
|
||||||
// if (!pred(target.front, source.front))
|
|
||||||
// {
|
|
||||||
// target.popFront();
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // found an equal *source and *target
|
|
||||||
// for (;;)
|
|
||||||
// {
|
|
||||||
// //@@@
|
|
||||||
// //move(source.front, target.front);
|
|
||||||
// target[0] = source[0];
|
|
||||||
// source.popFront();
|
|
||||||
// if (source.empty) break;
|
|
||||||
// if (!pred(target.front, source.front)) target.popFront();
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// return range(begin(r), target + 1);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// Ditto
|
|
||||||
// Range overwriteAdjacent(
|
|
||||||
// string fun = "a == b",
|
|
||||||
// alias move = .move,
|
|
||||||
// Range)(Range r)
|
|
||||||
// {
|
|
||||||
// return .overwriteAdjacent!(binaryFun!(fun), move, Range)(r);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// unittest
|
|
||||||
// {
|
|
||||||
// int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ];
|
|
||||||
// auto r = overwriteAdjacent(arr);
|
|
||||||
// assert(r == [ 1, 2, 3, 4, 5 ]);
|
|
||||||
// assert(arr == [ 1, 2, 3, 4, 5, 3, 4, 4, 4, 5 ]);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// eliminate
|
|
||||||
/* *
|
|
||||||
Reduces $(D r) by overwriting all elements $(D x) that satisfy $(D
|
|
||||||
pred(x)). Returns the reduced range.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
----
|
|
||||||
int[] arr = [ 1, 2, 3, 4, 5 ];
|
|
||||||
// eliminate even elements
|
|
||||||
auto r = eliminate!("(a & 1) == 0")(arr);
|
|
||||||
assert(r == [ 1, 3, 5 ]);
|
|
||||||
assert(arr == [ 1, 3, 5, 4, 5 ]);
|
|
||||||
----
|
|
||||||
*/
|
|
||||||
// Range eliminate(alias pred,
|
|
||||||
// SwapStrategy ss = SwapStrategy.unstable,
|
|
||||||
// alias move = .move,
|
|
||||||
// Range)(Range r)
|
|
||||||
// {
|
|
||||||
// alias It = Iterator!(Range);
|
|
||||||
// static void assignIter(It a, It b) { move(*b, *a); }
|
|
||||||
// return range(begin(r), partitionold!(not!(pred), ss, assignIter, Range)(r));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// unittest
|
|
||||||
// {
|
|
||||||
// int[] arr = [ 1, 2, 3, 4, 5 ];
|
|
||||||
// // eliminate even elements
|
|
||||||
// auto r = eliminate!("(a & 1) == 0")(arr);
|
|
||||||
// assert(find!("(a & 1) == 0")(r).empty);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* *
|
|
||||||
Reduces $(D r) by overwriting all elements $(D x) that satisfy $(D
|
|
||||||
pred(x, v)). Returns the reduced range.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
----
|
|
||||||
int[] arr = [ 1, 2, 3, 2, 4, 5, 2 ];
|
|
||||||
// keep elements different from 2
|
|
||||||
auto r = eliminate(arr, 2);
|
|
||||||
assert(r == [ 1, 3, 4, 5 ]);
|
|
||||||
assert(arr == [ 1, 3, 4, 5, 4, 5, 2 ]);
|
|
||||||
----
|
|
||||||
*/
|
|
||||||
// Range eliminate(alias pred = "a == b",
|
|
||||||
// SwapStrategy ss = SwapStrategy.semistable,
|
|
||||||
// Range, Value)(Range r, Value v)
|
|
||||||
// {
|
|
||||||
// alias It = Iterator!(Range);
|
|
||||||
// bool comp(typeof(*It) a) { return !binaryFun!(pred)(a, v); }
|
|
||||||
// static void assignIterB(It a, It b) { *a = *b; }
|
|
||||||
// return range(begin(r),
|
|
||||||
// partitionold!(comp,
|
|
||||||
// ss, assignIterB, Range)(r));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// unittest
|
|
||||||
// {
|
|
||||||
// int[] arr = [ 1, 2, 3, 2, 4, 5, 2 ];
|
|
||||||
// // keep elements different from 2
|
|
||||||
// auto r = eliminate(arr, 2);
|
|
||||||
// assert(r == [ 1, 3, 4, 5 ]);
|
|
||||||
// assert(arr == [ 1, 3, 4, 5, 4, 5, 2 ]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Specifies whether the output of certain algorithm is desired in sorted
|
Specifies whether the output of certain algorithm is desired in sorted
|
||||||
format.
|
format.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue