public IEmergingPattern Simplify(IEmergingPattern p) { EmergingPattern result = new EmergingPattern(p.Model, p.ClassFeature, p.ClassValue); if (p.Counts != null) { result.Counts = (double[])p.Counts.Clone(); } if (p.Supports != null) { result.Supports = (double[])p.Supports.Clone(); } _collection.SetResultCollection(result.Items); _collection.AddRange(p.Items); return(result); }
private async void RunFilter() { _delay?.Cancel(); _delay = new CancellationTokenSource(); try { await Task.Delay(500, _delay.Token); } catch (TaskCanceledException) { // request was canceled, return; return; } var currentText = _searchBox?.Text ?? string.Empty; var sourceCollection = SourceCollection.Cast <FileContainer>().ToList(); if (string.IsNullOrWhiteSpace(currentText)) { // When nothing is being filtered, we dont need to filter any thing. FilteredCollection.Clear(); FilteredCollection.AddRange(sourceCollection, true); } else { // Remove any items in the filtered collection that are no longer available in the primary collection var oldItems = (from x in FilteredCollection where !sourceCollection.Contains(x) select x).ToList(); oldItems.ForEach(x => FilteredCollection.Remove(x)); // look at existing filtered items and remove those that do not match the filter oldItems = (from x in FilteredCollection where !DoesContainString(x, currentText) select x).ToList(); oldItems.ForEach(x => FilteredCollection.Remove(x)); // Look at the source colleciton and find out what needs to be in the filtered collection var newItems = (from x in sourceCollection where DoesContainString(x, currentText) && !FilteredCollection.Contains(x) select x).ToList(); FilteredCollection.AddRange(newItems, true); } }