Commit graph

513 commits

Author SHA1 Message Date
H. S. Teoh
10afee97c4 Make joiner (with separator) work with forward ranges and transient ranges.
This is for the variant of joiner that takes a separator.

Restructure algorithm to not call .popFront while we're still using
.front.

Make sure we .save subranges when we're exporting .save, since RoR.save
does not guarantee the state of subranges are also .save'd.
2012-12-30 21:19:04 -08:00
monarch dodra
abc9b2fea6 typo 2012-12-29 17:47:49 +01:00
monarch dodra
4a7811a9dc Fix previous bug in countUntil
as pointed out by denish-sh. Also, more unittests.
2012-12-29 17:10:15 +01:00
unknown
d00be2ff1a Optimization in startsWith(Range, Needles...)
Basically, makes it stop searching as soon as an element as matched.

This is an important optimization, that avoids a lot of startsWith's other "non-optimzations"...
2012-12-26 16:24:55 +01:00
unknown
cfcdfbb7db Optimizations in startsWith
* Consolidate implementation by checking length in a single spot.
* Checks narrow string or the same types' lengths.
* Index iterates on all RA ranges (and not just Arrays).

Ends with was left untouched, because it forwards to startsWith anyways.
2012-12-26 16:24:53 +01:00
unknown
a0f18336b0 Bit of unicode unittest in [starts|ends]With
Just sprinkling some tests. These covered a wee little bit of missing usecases.
2012-12-26 16:24:52 +01:00
unknown
1b4186b16e Clean up endsWith unittests
Original author wrote "wrap" because filter is not bidirectional. However, the function filterBidirectional fits the need, so migrating to that.
2012-12-26 16:24:52 +01:00
unknown
3270e9a4e1 "Ranges..." => "Needles..." in [starts|ends]With.
To avoid any confusion: The stuff in ranges may or may not actually be ranges. generic "Needles" is what best describes it.
2012-12-26 16:24:41 +01:00
Peter Alexander
14b7095bd8 Simplified std.algorithm.copy array overlap test.
The array overlap test in std.algorithm.copy did an unnecessary amount of comparisons. This pull request simplifies it.
2012-12-25 18:13:35 +00:00
Walter Bright
bbcd9a5d3c Merge branch 'master' of github.com:D-Programming-Language/phobos 2012-12-24 20:16:39 -08:00
Walter Bright
ef0bed7d15 fix memory corruption bug in unittest 2012-12-24 20:16:19 -08:00
Andrei Alexandrescu
58fde7057f Merge pull request #1024 from monarchdodra/countStarts
performance tweaks for countUntil
2012-12-24 09:44:02 -08:00
Andrei Alexandrescu
c1f8609e1f Merge pull request #1013 from Poita/endsWithRefactor
Refactored endsWith to use retro + startsWith.
2012-12-23 19:52:00 -08:00
unknown
f8782c37d9 performance tweaks for countUntil 2012-12-22 00:03:34 +01:00
H. S. Teoh
f687885a76 No need to use .save on inner range if we aren't going to export .save. 2012-12-20 10:20:30 -08:00
H. S. Teoh
7ff2fcec06 Fix issue 8061.
We cannot assume that RoR.save will also .save the state of its
subranges; so the only way we can correctly export a .save method in the
joined range is if we also .save its subranges as we traverse over them.
2012-12-20 10:03:43 -08:00
Andrei Alexandrescu
af12683895 Merge pull request #854 from jmdavis/hasSlicing
Improvements to hasSlicing
2012-12-17 21:38:26 -08:00
Walter Bright
3b683d99bf Merge pull request #1004 from 9rnsr/fix9060
Issue 9060 - std.range.chain and std.range.zip cannot get frame pointer
2012-12-17 21:02:38 -08:00
Alex Rønne Petersen
cc3176ab76 Merge pull request #1015 from monarchdodra/spaces
Removing trailing spaces in algorithm
2012-12-17 17:05:46 -08:00
k-hara
46b612de08 fix Issue 9060 - std.range.chain and std.range.zip cannot get frame pointer
Changes to avoid following two errors:
* "cannot access frame pointer"
* "field xxx must be initialized in constructor, because it is nested struct"
2012-12-18 09:22:24 +09:00
unknown
027804bc28 Removing trailing spaces 2012-12-17 18:54:47 +01:00
jmdavis
57ddea7cf2 Fix to Map caused by changes to hasSlicing.
import std.algorithm;
import std.range;

void main()
{
    auto N2 = sequence!"n"(cast(size_t)1).map!"a";
}

ceased to compile, because Map's opSlice won't work anymore over
infinite ranges, because the result can't be reassigned to the original.
2012-12-16 22:28:17 -08:00
jmdavis
7d5d9fb1c0 Some whitespace cleanup. 2012-12-16 22:28:16 -08:00
H. S. Teoh
3a2377ccd3 Replace joiner unittest with one that doesn't suffer from issue 9131. 2012-12-16 21:35:22 -08:00
H. S. Teoh
e471f8ee13 Completely get rid of UTF-8 to workaround OSX/64 bug. 2012-12-16 21:35:22 -08:00
H. S. Teoh
f83ad8a572 Add unittest for new joiner. 2012-12-16 21:35:22 -08:00
H. S. Teoh
d489281292 Rewrite joiner to not assume persistence of .front. 2012-12-16 21:35:22 -08:00
Peter Alexander
0c52706eb6 Refactored endsWith to use retro + startsWith.
What's the point of having all these powerful, generic, abstract functions if we're just going to copy and paste code? :-)

This change has several benefits:

* It is far more elegant.
* Changes (optimisations) to startsWith automatically carry across to endsWith.
* We get extra testing for startsWith and retro for free.
2012-12-17 02:08:39 +00:00
Hara Kenji
194ca07803 Merge pull request #1011 from blackwhale/fix-multisort
fix issue 9160 multiSort constraint regression
2012-12-16 17:34:09 -08:00
Peter Alexander
b7472c4e39 Corrected constraints for std.algorithm.endsWith
Previously endsWith constraints only required input ranges, but the algorithm uses `back` and `popBack` within, so clearly a bidirectional range is needed.
2012-12-15 23:20:20 +00:00
Dmitry Olshansky
bde7cbad4d fix issue 9160 multiSort constraint bug 2012-12-15 18:07:57 +04:00
Andrei Alexandrescu
1b2b5fb76e Merge pull request #951 from monarchdodra/count3
improvements/fixes for count countUntil
2012-12-13 09:17:47 -08:00
monarch dodra
e8d320f82f imporvements to uninitializedFill && initializeAll
Because they didn't really handle all of the cases correctly.

Added unittests.
2012-12-13 17:34:57 +01:00
Andrei Alexandrescu
0fcca44b8d Merge pull request #787 from blackwhale/loan-stable-sort
fix stable sort (4584)
2012-12-12 07:38:10 -08:00
jmdavis
74f8c844fe Revert "Add alias opDollar and use $ in range slicing"
This reverts commit 07104b5fe6.

As we cannot currenly rely on even ranges with slicing implementing
opDollar, this change breaks code, because it assumes that such ranges
implement opDollar.
2012-12-09 17:21:37 -08:00
lomereiter
9f8669b567 changed return type of NWayUnion.front to auto ref 2012-12-09 22:12:53 +04:00
k-hara
07104b5fe6 Add alias opDollar and use $ in range slicing 2012-12-05 10:13:17 +09:00
k-hara
58a8ccf42e Fix for moveFront, moveBack, and moveAt
- I assume they are not properties, then changed to normal functions.
- Global .moveFront/Back uses front and back if member moveFront/back doesn't exist.
  Then, member aliases are just redundant.
2012-12-03 00:53:52 +09:00
jmdavis
20341b4980 Implement issue# 9103.
find should work with multiple needles which are a combination of
elements and ranges rather than just all ranges - just like startsWith
and endsWith do - and since that overload of find calls startsWith, it's
trivial to make it take the same types of arguments as startsWith.
2012-12-02 01:53:29 -08:00
k-hara
0c88021d4b Add more test case 2012-11-25 17:23:33 +09:00
k-hara
a404b3108f Change module level functions to nested class static member. 2012-11-25 15:52:42 +09:00
k-hara
cd432f7b2f Add forward template 2012-11-25 13:47:00 +09:00
Dmitry Olshansky
3aa8e20371 extra test to make sure stable sort of non-lvalue ranges compiles & works 2012-11-23 23:52:01 +04:00
Dmitry Olshansky
dca2a007a2 whitespace & std.algortihm style unification 2012-11-23 23:18:12 +04:00
Dmitry Olshansky
585a9a241a add stable sort, tweaks to std.algorithm 2012-11-23 22:58:02 +04:00
k-hara
01df2f60be Remove redundant parenthesis for getters, and use assignment syntax for setters 2012-11-23 15:07:17 +09:00
monarch dodra
20d77cb8ff Changes to count[Until] as suggested by review 2012-11-22 20:35:24 +01:00
k-hara
28dedee456 Issue 7444 - Require [] for array copies too 2012-11-20 17:55:21 +09:00
monarch dodra
076c853b73 indexOf: More details
Not 100% about the text...
2012-11-20 09:05:52 +01:00
monarch dodra
0a3b7be8e1 Quick splitter countUntil fix
This is more of a band-aid..., splitter needs some deep fixing anyways...
2012-11-20 09:05:51 +01:00