Merge branch 'master' into rework-filter-and-view
This commit is contained in:
commit
998f74c18d
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace ObservableCollections
|
namespace ObservableCollections
|
||||||
{
|
{
|
||||||
@ -18,12 +19,27 @@ namespace ObservableCollections
|
|||||||
this.dictionary = new Dictionary<TKey, TValue>();
|
this.dictionary = new Dictionary<TKey, TValue>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection)
|
public ObservableDictionary(IEqualityComparer<TKey>? comparer)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
this.dictionary = new Dictionary<TKey, TValue>(comparer: comparer);
|
||||||
this.dictionary = new Dictionary<TKey, TValue>(collection);
|
}
|
||||||
|
|
||||||
|
public ObservableDictionary(int capacity, IEqualityComparer<TKey>? comparer)
|
||||||
|
{
|
||||||
|
this.dictionary = new Dictionary<TKey, TValue>(capacity, comparer: comparer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection)
|
||||||
|
: this(collection, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection, IEqualityComparer<TKey>? comparer)
|
||||||
|
{
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||||
|
this.dictionary = new Dictionary<TKey, TValue>(collection: collection, comparer: comparer);
|
||||||
#else
|
#else
|
||||||
this.dictionary = new Dictionary<TKey, TValue>();
|
this.dictionary = new Dictionary<TKey, TValue>(comparer: comparer);
|
||||||
foreach (var item in collection)
|
foreach (var item in collection)
|
||||||
{
|
{
|
||||||
dictionary.Add(item.Key, item.Value);
|
dictionary.Add(item.Key, item.Value);
|
||||||
@ -224,5 +240,16 @@ namespace ObservableCollections
|
|||||||
{
|
{
|
||||||
return GetEnumerator();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEqualityComparer<TKey> Comparer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
return dictionary.Comparer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,33 @@ namespace ObservableCollections
|
|||||||
this.set = new HashSet<T>();
|
this.set = new HashSet<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableHashSet(IEqualityComparer<T>? comparer)
|
||||||
|
{
|
||||||
|
this.set = new HashSet<T>(comparer: comparer);
|
||||||
|
}
|
||||||
|
|
||||||
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
|
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
|
||||||
|
|
||||||
public ObservableHashSet(int capacity)
|
public ObservableHashSet(int capacity)
|
||||||
{
|
{
|
||||||
this.set = new HashSet<T>(capacity);
|
this.set = new HashSet<T>(capacity: capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableHashSet(int capacity, IEqualityComparer<T>? comparer)
|
||||||
|
{
|
||||||
|
this.set = new HashSet<T>(capacity: capacity, comparer: comparer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public ObservableHashSet(IEnumerable<T> collection)
|
public ObservableHashSet(IEnumerable<T> collection)
|
||||||
{
|
{
|
||||||
this.set = new HashSet<T>(collection);
|
this.set = new HashSet<T>(collection: collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableHashSet(IEnumerable<T> collection, IEqualityComparer<T>? comparer)
|
||||||
|
{
|
||||||
|
this.set = new HashSet<T>(collection: collection, comparer: comparer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event NotifyCollectionChangedEventHandler<T>? CollectionChanged;
|
public event NotifyCollectionChangedEventHandler<T>? CollectionChanged;
|
||||||
@ -185,7 +200,7 @@ namespace ObservableCollections
|
|||||||
|
|
||||||
public bool TryGetValue(T equalValue, [MaybeNullWhen(false)] out T actualValue)
|
public bool TryGetValue(T equalValue, [MaybeNullWhen(false)] out T actualValue)
|
||||||
{
|
{
|
||||||
lock(SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
return set.TryGetValue(equalValue, out actualValue);
|
return set.TryGetValue(equalValue, out actualValue);
|
||||||
}
|
}
|
||||||
@ -264,5 +279,16 @@ namespace ObservableCollections
|
|||||||
{
|
{
|
||||||
return GetEnumerator();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEqualityComparer<T> Comparer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
return set.Comparer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ namespace ObservableCollections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryPeek([MaybeNullWhen(false)] T result)
|
public bool TryPeek([MaybeNullWhen(false)] out T result)
|
||||||
{
|
{
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user