public QGramSet <T> Union(QGramSet <T> set) { var newQgramSet = new QGramSet <T>(this); foreach (var pair in set) { int frequency; newQgramSet.TryGetValue(pair.Key, out frequency); newQgramSet[pair.Key] = Math.Max(pair.Value, frequency); } return(newQgramSet); }
public QGramSet <T> Intersect(QGramSet <T> set) { var newQgramSet = new QGramSet <T>(); foreach (var pair in set) { int frequency; if (TryGetValue(pair.Key, out frequency)) { newQgramSet.Add(pair.Key, Math.Min(pair.Value, frequency)); } } return(newQgramSet); }