public void RemoveTest() { ImmutableSegmentedList <int> list = ImmutableSegmentedList <int> .Empty; for (int i = 1; i <= 10; i++) { list = list.Add(i * 10); } list = list.Remove(30); Assert.Equal(9, list.Count); Assert.False(list.Contains(30)); list = list.Remove(100); Assert.Equal(8, list.Count); Assert.False(list.Contains(100)); list = list.Remove(10); Assert.Equal(7, list.Count); Assert.False(list.Contains(10)); var removeList = new int[] { 20, 70 }; list = list.RemoveAll(removeList.Contains); Assert.Equal(5, list.Count); Assert.False(list.Contains(20)); Assert.False(list.Contains(70)); System.Collections.Immutable.IImmutableList <int> list2 = ImmutableSegmentedList <int> .Empty; for (int i = 1; i <= 10; i++) { list2 = list2.Add(i * 10); } list2 = System.Collections.Immutable.ImmutableList.Remove(list2, 30); Assert.Equal(9, list2.Count); Assert.False(list2.Contains(30)); list2 = System.Collections.Immutable.ImmutableList.Remove(list2, 100); Assert.Equal(8, list2.Count); Assert.False(list2.Contains(100)); list2 = System.Collections.Immutable.ImmutableList.Remove(list2, 10); Assert.Equal(7, list2.Count); Assert.False(list2.Contains(10)); list2 = list2.RemoveAll(removeList.Contains); Assert.Equal(5, list2.Count); Assert.False(list2.Contains(20)); Assert.False(list2.Contains(70)); }
private async ValueTask ProcessEventChangeAsync(ImmutableSegmentedList <bool> changes, CancellationToken cancellationToken) { await _dataSource.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // no point preceding if we're already disposed. We check this on the UI thread so that we will know // about any prior disposal on the UI thread. if (cancellationToken.IsCancellationRequested) { return; } // If any of the requests was high priority, then compute at that speed. var highPriority = changes.Contains(true); await RecomputeTagsAsync(highPriority, cancellationToken).ConfigureAwait(false); }