Commit a42067d7 authored by Anton Bukov's avatar Anton Bukov

Merge pull request #3 from jell0nek/master

skipWhile_i improvements
parents 84617bbb 5a1c6f99
......@@ -19,8 +19,6 @@ TEST(SkipWhileRange, ManyToMore)
auto rng = from(src);
auto dst = rng.skipWhile([](int it){return it < 0 || it > 10;});
auto vec = dst.toVector();
CheckRangeEqArray(dst, ans);
}
......
......@@ -192,16 +192,17 @@ namespace boolinq
LinqObj<Enumerator<T,std::pair<TE,int> > > skipWhile_i(std::function<bool(T,int)> predicate) const
{
return Enumerator<T,std::pair<TE,int> >([=](std::pair<TE,int> & pair)->T{
if (pair.second != 0)
return pair.first.nextObject();
T object;
do
object = pair.first.nextObject();
while (predicate(object,pair.second++));
return object;
}, std::make_pair(_enumerator,0));
return Enumerator<T,std::pair<TE,int> >([=](std::pair<TE,int> & pair)->T{
if (pair.second != 0)
return pair.first.nextObject();
T object;
do
object = pair.first.nextObject();
while (predicate(object,pair.second++));
return object;
}, std::make_pair(_enumerator,0));
}
LinqObj<Enumerator<T,std::pair<TE,int> > > skipWhile(std::function<bool(T)> predicate) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment