Skip to content

Instantly share code, notes, and snippets.

@neuecc
Created July 29, 2021 01:57
Show Gist options
  • Select an option

  • Save neuecc/e0b8b7c488f58eb004c04dcc5be466cf to your computer and use it in GitHub Desktop.

Select an option

Save neuecc/e0b8b7c488f58eb004c04dcc5be466cf to your computer and use it in GitHub Desktop.
// similar as ObservableCollection <-> CollectionView
public delegate void NotifyCollectionChangedEventHandler<T>(in NotifyCollectionChangedEventArgs<T> e);
public interface INotifyCollectionChanged<T>
{
event NotifyCollectionChangedEventHandler<T>? CollectionChanged;
ISynchronizedView<T, TView> CreateView<TView>(Func<T, TView> transform, bool reverse = false);
ISynchronizedView<T, TView> CreateSortedView<TView>(Func<T, TView> transform, IComparer<T> comparer);
IGroupedSynchronizedView<T, TKey, TView> CreateGroupedView<TKey, TView>(Func<T, TKey> keySelector, Func<T, TView> transform);
}
public readonly ref struct NotifyCollectionChangedEventArgs<T>
{
public readonly NotifyCollectionChangedAction Action;
public readonly ReadOnlySpan<T> NewItems;
public readonly ReadOnlySpan<T> OldItems;
public readonly int NewStartingIndex;
public readonly int OldStartingIndex;
// ctor()
}
public interface ISynchronizedView<T, TView> : IReadOnlyList<TView>, IDisposable
{
void AttachFilter(Func<T, TView> filter);
void ResetFilter();
}
public interface IGroupedSynchronizedView<T, TKey, TView> : IGrouping<TKey, TView>, IDisposable
{
void AttachFilter(Func<T, TView> filter);
void ResetFilter();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment