Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Dictionary<string, SortedSet<int>> CountStream()
- {
- Dictionary<string, SortedSet<int>> dctWords = new Dictionary<string, SortedSet<int>>();
- string buffer = string.Empty;
- foreach (char ch in sToSearch)
- {
- buffer += ch;
- foreach(string word in lstSearchFor) {
- int iSearchIndex = 0;
- while ((iSearchIndex = buffer.IndexOf(word, iSearchIndex)) != -1)
- {
- if (!dctWords.ContainsKey(word))
- {
- dctWords.Add(word, new SortedSet<int>());
- dctWords[word].Add(iSearchIndex);
- }
- else
- {
- if (!dctWords[word].Contains(iSearchIndex))
- dctWords[word].Add(iSearchIndex);
- }
- iSearchIndex++;
- }
- }
- }
- return dctWords;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement