A standalone full-text search engine written in C#.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
677 B

using System;
using System.Collections.Generic;
using System.IO;
namespace SBRL.Utilities
{
static class LineIterator {
public static IEnumerable<string> GetLines(TextReader source)
{
string nextLine;
while ((nextLine = source.ReadLine()) != null) {
yield return nextLine;
}
}
public static IEnumerable<string> GetLines(string source)
{
source = source.Replace("\r\n", "\n");
int curPosition = 0, nextIndex;
while (true)
{
nextIndex = source.IndexOf("\n", curPosition);
if (nextIndex == -1)
break;
yield return source.Substring(curPosition, nextIndex - curPosition);
curPosition = nextIndex + 1;
}
}
}
}