Commit graph

639 commits

Author SHA1 Message Date
Brad Roberts
3200b08644 Improve find's @safety 2014-10-13 00:01:14 -07:00
H. S. Teoh
95f143f279 Refactor to eliminate redundant call to r.empty.
.savePrev and .prev should be private.
2014-10-05 19:31:09 -07:00
H. S. Teoh
70bec52d34 Move std.range.chunkBy to std.algorithm.groupBy. 2014-10-05 19:31:09 -07:00
H. S. Teoh
95222b884d Merge pull request #2582 from monarchdodra/cacheBug
Tweak cache constructor
2014-10-03 07:54:48 -07:00
monarchdodra
282fc0189e Tweak cache constructor 2014-10-03 16:08:46 +02:00
Vladimir Panteleev
c8242fe580 std.algorithm: Add cache and cacheBidirectional to the cheat sheet 2014-10-02 14:28:35 +00:00
Dmitry Olshansky
83e90a86c4 Merge pull request #1364 from monarchdodra/cache
Range adaptor: cache
2014-09-25 14:36:46 +04:00
Jakob Ovrum
8169a4aa59 Tweak #2532 2014-09-21 02:19:33 +09:00
Daniel Murphy
2bd311c0ed Merge pull request #2534 from quickfur/issue13091
Use new cartesianProduct implementation for 2-argument case as well.
2014-09-19 18:40:48 +10:00
H. S. Teoh
a432798f15 Bug number shouldn't appear in ddocs! 2014-09-18 17:55:44 -07:00
H. S. Teoh
556ef61ef8 Use new cartesianProduct implementation for 2-argument case as well.
The original implementation will now only be used when one or both the
ranges is either non-forward or infinite. The new implementation is also
more attribute-friendly (works with pure, nothrow, @nogc, @safe), so
this also fixes issue 13091.
2014-09-18 17:43:09 -07:00
H. S. Teoh
0b6bfd5aa7 Cross-reference among from canFind.
For newbies' ease of discovering the right function to use (issue 13467).
2014-09-18 13:02:43 -07:00
monarch dodra
ebcc18e387 Range adaptor: cache
As discussed in this thread:
http://forum.dlang.org/thread/ovbjcmogezbvsxrwfcol@forum.dlang.org

This provides a range adaptor that cache the result of another range.

Meant as a lazy alternative to array. Not much else to say...?

Documentation might suck.
2014-09-16 21:43:26 +02:00
H. S. Teoh
575b4aec7f Merge pull request #1266 from idanarye/add-functional-pattern-matching-for-object-references
fix issue 9959 - Add functional pattern matching for object references
2014-09-16 07:15:10 -07:00
Vladimir Panteleev
c506b03ec4 fix Issue 13441 - joiner asserts with only(x) separator 2014-09-09 11:35:20 +00:00
Per Nordlöw
7f3611a5ed Add empty check for haystack range r in skipOver()
Remove space
2014-09-02 14:28:35 +02:00
H. S. Teoh
6c53bfc58f Use auto instead of explicit array type. 2014-08-30 07:09:57 -07:00
H. S. Teoh
76db0de19c Eliminate C-style array declarations. 2014-08-30 06:51:27 -07:00
monarch dodra
dd4b204d5b Merge pull request #2473 from quickfur/issue13393
Fix regression 13393: cartesianProduct + joiner = runtime assertion failure
2014-08-30 00:10:29 +02:00
H. S. Teoh
6e31087817 Simplify unittest. 2014-08-28 17:03:07 -07:00
H. S. Teoh
ca96460a1e Fix regression 13393.
Caused by .save failing to save entire state, causing inconsistency in
.save'd objects.
2014-08-28 16:49:24 -07:00
Peter Alexander
5e0532b9e7 Fix Issue 10460 - auto ref for Union, SetDifference, SetSymmetricDifference
https://issues.dlang.org/show_bug.cgi?id=10460

The rearrangement of SetSymmetricDifference.front was needed since auto ref doesn't deduce correctly when there are multiple return statements (by design), so a single return statement with the ternary operator was used.
2014-08-25 13:32:34 +01:00
Михаил Страшун
bfebba8683 Merge pull request #2431 from monarchdodra/13304
Fix reduce regression 13304.
2014-08-21 22:30:51 +02:00
monarchdodra
76f994abf9 Fix reduce regression 13304.
Also cover test case 10709.
2014-08-21 20:17:22 +02:00
Михаил Страшун
676290c36d Merge pull request #2415 from quickfur/issue13257
Workaround deprecation of splitter.{back,popBack} in std.algorithm.map.
2014-08-18 22:07:03 +02:00
IdanArye
cf1aa96bc4 fix issue 9959 - Add functional pattern matching for object references
Add the function std.algorithm.castSwitch, which chooses a delegate
based on the class of an object and run that delegate with that object.
2014-08-18 22:15:00 +03:00
H. S. Teoh
3c6efdf4e3 Reenable ancient failing unittest.
Fix unittest to not require unreasonable amounts of stack space.
2014-08-13 11:32:20 -07:00
H. S. Teoh
b97b396864 Workaround deprecation of splitter.{back,popBack} in std.algorithm.map. 2014-08-10 15:47:13 -07:00
IdanArye
0318f0ffba fix issue 9942 - Add a functional switch function
std.algorithm.predSwitch is the functional version of the `switch`
statement(without a lookup table).
2014-08-09 17:13:15 +03:00
Dmitry Olshansky
53de1da98b Merge pull request #2060 from monarchdodra/reduceReimpl
Re-implement reduce
2014-07-28 03:59:46 +04:00
monarchdodra
096ae6ab87 Use assertThrown in reduce unittest 2014-07-27 22:59:07 +02:00
monarchdodra
2572cef9d4 Reduce unittest for 10709, 12569, and...
...an unfiled issue from the forums
2014-07-27 22:59:07 +02:00
monarch dodra
91d1864c2f Re-implement reduce.
Consolidates the implementation, prepares for "fold", and also fixes a couple of issues:
http://forum.dlang.org/thread/oghtttkopzjshsuflelk@forum.dlang.org
https://issues.dlang.org/show_bug.cgi?id=10709
https://issues.dlang.org/show_bug.cgi?id=12569
2014-07-27 22:59:07 +02:00
monarchdodra
9d158ba52d Fix Issue 8866 - Splitter(R1, R2) CANNOT be bidirectional. 2014-07-27 18:35:25 +02:00
Nils Boßung
4ebca8c2bd change |= to || 2014-07-23 14:22:03 +02:00
Nils Boßung
a6da3ece06 fix Issue 13171 - std.algorithm.until(range, sentinel, OpenRight.no) doesn't propagate popping of sentinel to range 2014-07-20 23:39:49 +02:00
sinkuu
e989418fa5 Use unsigned-safe comparing in clamp contract 2014-07-19 08:10:25 +09:00
Dicebot
fe230e674f Mention 'clamp' in the cheatsheet 2014-07-17 14:51:48 +02:00
Dicebot
8dc16d8109 Add in contract for clamp()
lower bound should not be larger than higher one
2014-07-17 14:47:34 +02:00
Dicebot
136e8661b6 Adjust clamp signature and tests
signed is now deduced over unsigned, added small documented unittest
instead of full block
2014-07-17 14:47:34 +02:00
Andreas Zwinkau
5cde6f5fd5 Add clamp function
Request in issue 10039

http://d.puremagic.com/issues/show_bug.cgi?id=10039
2014-07-17 14:47:34 +02:00
Dmitry Olshansky
1f4c14a067 Merge pull request #2195 from JamesDavidCarr/master
Changed distance() to be more memory efficient based on email from mailing list.
2014-07-17 00:40:57 +04:00
Михаил Страшун
04dee6bfe5 Merge pull request #2328 from quickfur/issue10693
Fix range violation for cartesianProduct of empty ranges.
2014-07-15 00:06:47 +03:00
H. S. Teoh
5f0155b0c8 .init value of cartesianProduct should be empty. 2014-07-14 12:47:28 -07:00
James Carr
0a7d2c9b10 Removed the accidental semicolon 2014-07-13 15:21:05 +01:00
James Carr
4beda7da9c Changed the implementation of distance() so that it uses the memory inefficient version to prevent breakage in the API. Efficient version has been moved to distanceLowMem() in the struct and is called internally by levenshteinDistance() 2014-07-13 14:01:56 +01:00
James Carr
5102e9e273 Removed calls to matrix() in distance()
Since _matrix is now a single dimension matrix, calls to matrix() have
been removed and replaced with direct access equivalents.
2014-07-13 13:26:38 +01:00
James Carr
3e037f463e Refactored distance() and corrected path()
Refactored distacen() so that it now accepts the lengths of the ranges
because we already calculate these in levenshteinDistance().

Altered ss in distance() and tt in distanceWithPath().

Moved popFront()’s to after their final usage to handle transitive
ranges.

Corrected path() so that it calls distanceWithPath() instead of
distance().
2014-07-13 13:26:38 +01:00
James Carr
0d0a2c0308 Refactored, added unit tests and removed opIndex.
Moved checks for which Range is longer to levenshteinDistance() method.

Reverted to implementation found in original distance() with regards to
using front/popFront instead of opIndex.

Fixed formatting of return statement.

Added two unit tests for levenshteinDistance().

Credit to @Poita.
2014-07-13 13:26:38 +01:00
James Carr
a9ae1023a2 Moved previous distance() implementation
Moved to be a private method and only expose new more memory efficient
distance(). This is done because we need the old implementation for
path(). Modified levenshteinDistanceAndPath() to use the old distance()
to reflect this.
2014-07-13 13:26:37 +01:00