Skip to content

Commit

Permalink
Add import declarations for issue 313 & 314
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Dec 24, 2013
1 parent 2f4552e commit 3e791f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 15 additions & 3 deletions std/algorithm.d
Expand Up @@ -2758,7 +2758,12 @@ private struct SplitterResult(alias isTerminator, Range)

@property auto front()
{
version(assert) if (empty) throw new RangeError();
version(assert)
{
import core.exception : RangeError;
if (empty)
throw new RangeError();
}
static if (fullSlicing)
return _input[0 .. _end];
else
Expand All @@ -2767,7 +2772,12 @@ private struct SplitterResult(alias isTerminator, Range)

void popFront()
{
version(assert) if (empty) throw new RangeError();
version(assert)
{
import core.exception : RangeError;
if (empty)
throw new RangeError();
}

static if (fullSlicing)
{
Expand Down Expand Up @@ -6160,6 +6170,8 @@ size_t count(alias pred = "a == b", Range, E)(Range haystack, E needle)
///
unittest
{
import std.uni : toLower;

// count elements in range
int[] a = [ 1, 2, 4, 3, 2, 5, 3, 2, 4 ];
assert(count(a, 2) == 3);
Expand All @@ -6169,7 +6181,7 @@ unittest
assert(count("ababab", "abab") == 1);
assert(count("ababab", "abx") == 0);
// fuzzy count range in range
assert(count!"std.uni.toLower(a) == std.uni.toLower(b)"("AbcAdFaBf", "ab") == 2);
assert(count!((a, b) => std.uni.toLower(a) == std.uni.toLower(b))("AbcAdFaBf", "ab") == 2);
// count predicate in range
assert(count!("a > 1")(a) == 8);
}
Expand Down
6 changes: 6 additions & 0 deletions std/uni.d
Expand Up @@ -1479,6 +1479,8 @@ private auto packedArrayView(T)(inout(size_t)* ptr, size_t items) @trusted pure
// Partially unrolled binary search using Shar's method
//============================================================================

private import std.math : pow;

string genUnrolledSwitchSearch(size_t size)
{
assert(isPowerOf2(size));
Expand Down Expand Up @@ -5812,6 +5814,8 @@ int sicmp(S1, S2)(S1 str1, S2 str2)
if(isForwardRange!S1 && is(Unqual!(ElementType!S1) == dchar)
&& isForwardRange!S2 && is(Unqual!(ElementType!S2) == dchar))
{
import std.utf : decode;

alias sTable = simpleCaseTable;
size_t ridx=0;
foreach(dchar lhs; str1)
Expand Down Expand Up @@ -6532,6 +6536,8 @@ private auto splitNormalized(NormalizationForm norm, C)(const(C)[] input)

private auto seekStable(NormalizationForm norm, C)(size_t idx, in C[] input)
{
import std.utf : codeLength;

auto br = input[0..idx];
size_t region_start = 0;// default
for(;;)
Expand Down

0 comments on commit 3e791f6

Please sign in to comment.