Skip to content

Instantly share code, notes, and snippets.

View popcatalin81's full-sized avatar

Catalin Pop popcatalin81

View GitHub Profile
@popcatalin81
popcatalin81 / MyExtensions.cs
Created October 15, 2020 17:02
My Linqpad ultils
/// <summary>
/// Extensions class with enumerable extensions targeted at code generation
/// </summary>
public static class EnumerableExtensions
{
/// <summary>
/// Yields a single value
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="instance"></param>
public class Indexer
{
private Dictionary<string, HashSet<string>> terms = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
private Dictionary<string, HashSet<string>> docTerms = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
public void Index(string docId, string text)
{
var words = new HashSet<string>(text.Split(), StringComparer.OrdinalIgnoreCase);
HashSet<string> toRemove;
if (docTerms.TryGetValue(docId, out toRemove))