日期:2014-05-17 浏览次数:20471 次
List<int> TakeWhile(List<int> data, Func<int, int, bool> f)
{
List<int> result = new List<int>();
int index = 0;
bool isTake = false;
foreach (int i in data)
{
if (!isTake && f(i, index)) isTake = true;
if (isTake) result.Add(i);
}
return result;
}