Class BindableHashSet<T>
- Namespace
- Bindables
- Assembly
- Bindables.dll
A bindable hash set implementation that raises events when the set or its elements are modified. Supports change notifications at both the set level and individual element level.
[Serializable]
public class BindableHashSet<T> : Bindable<HashSet<T>>, IBindWritable<HashSet<T>>, IBindWritable, IEquatable<HashSet<T>>, IEquatable<Bindable<HashSet<T>>>, IBindableHashSet<T>, IBindable<HashSet<T>>, IBindable, IReadOnlyCollection<T>, ISet<T>, ICollection<T>, IEnumerable<T>, IEnumerable, ISerializable, IDeserializationCallback
Type Parameters
TThe type of elements in the set.
- Inheritance
-
BindableHashSet<T>
- Implements
-
IBindWritable<HashSet<T>>IEquatable<HashSet<T>>ISet<T>ICollection<T>IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
BindableHashSet()
Initializes a new instance of the BindableHashSet<T> class that is empty.
public BindableHashSet()
BindableHashSet(IEnumerable<T>)
Initializes a new instance of the BindableHashSet<T> class that contains elements copied from the specified collection.
public BindableHashSet(IEnumerable<T> collection)
Parameters
collectionIEnumerable<T>The collection whose elements are copied to the new set.
BindableHashSet(IEnumerable<T>, IEqualityComparer<T>)
Initializes a new instance of the BindableHashSet<T> class that contains elements copied from the specified collection and uses the specified comparer.
public BindableHashSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
collectionIEnumerable<T>The collection whose elements are copied to the new set.
comparerIEqualityComparer<T>The equality comparer to use when comparing elements.
BindableHashSet(IEqualityComparer<T>)
Initializes a new instance of the BindableHashSet<T> class that uses the specified comparer.
public BindableHashSet(IEqualityComparer<T> comparer)
Parameters
comparerIEqualityComparer<T>The equality comparer to use when comparing elements.
Properties
BindableCount
Gets a bindable property for the count of elements in the set. This allows observing changes to the set count.
public IBindable<int> BindableCount { get; }
Property Value
Comparer
Gets the equality comparer used to determine equality for the values in the set.
public IEqualityComparer<T> Comparer { get; }
Property Value
Count
public int Count { get; }
Property Value
IsReadOnly
public bool IsReadOnly { get; }
Property Value
Value
Gets or sets the underlying hash set value. Setting this property replaces the entire set and raises the Changed event.
public HashSet<T> Value { get; set; }
Property Value
- HashSet<T>
Methods
Add(T)
Adds the specified element to the set and raises the OnElementAdd event if the element was added.
public bool Add(T item)
Parameters
itemTThe element to add to the set.
Returns
- bool
true if the element was added; false if it was already present.
Clear()
Removes all elements from the set and raises the Changed event if the set was not empty.
public void Clear()
Contains(T)
public bool Contains(T item)
Parameters
itemT
Returns
CopyTo(T[])
Copies the elements of the set to an array.
public void CopyTo(T[] array)
Parameters
arrayT[]The one-dimensional array that is the destination of the elements copied from the set.
CopyTo(T[], int)
public void CopyTo(T[] array, int arrayIndex)
Parameters
arrayT[]arrayIndexint
CopyTo(T[], int, int)
Copies the specified number of elements of the set to an array, starting at the specified array index.
public void CopyTo(T[] array, int arrayIndex, int count)
Parameters
arrayT[]The one-dimensional array that is the destination of the elements copied from the set.
arrayIndexintThe zero-based index in array at which copying begins.
countintThe number of elements to copy.
ExceptWith(IEnumerable<T>)
Removes all elements in the specified collection from the current set. Raises the OnElementRemove event for each removed element.
public void ExceptWith(IEnumerable<T> other)
Parameters
otherIEnumerable<T>The collection of items to remove from the set.
GetEnumerator()
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
GetObjectData(SerializationInfo, StreamingContext)
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfocontextStreamingContext
IntersectWith(IEnumerable<T>)
Modifies the current set so that it contains only elements that are also in a specified collection. Raises the OnElementRemove event for each removed element.
public void IntersectWith(IEnumerable<T> other)
Parameters
otherIEnumerable<T>The collection to compare to the current set.
IsProperSubsetOf(IEnumerable<T>)
public bool IsProperSubsetOf(IEnumerable<T> other)
Parameters
otherIEnumerable<T>
Returns
IsProperSupersetOf(IEnumerable<T>)
public bool IsProperSupersetOf(IEnumerable<T> other)
Parameters
otherIEnumerable<T>
Returns
IsSubsetOf(IEnumerable<T>)
public bool IsSubsetOf(IEnumerable<T> other)
Parameters
otherIEnumerable<T>
Returns
IsSupersetOf(IEnumerable<T>)
public bool IsSupersetOf(IEnumerable<T> other)
Parameters
otherIEnumerable<T>
Returns
OnDeserialization(object)
public void OnDeserialization(object sender)
Parameters
senderobject
Overlaps(IEnumerable<T>)
public bool Overlaps(IEnumerable<T> other)
Parameters
otherIEnumerable<T>
Returns
Remove(T)
Removes the specified element from the set and raises the OnElementRemove event if the element was removed.
public bool Remove(T item)
Parameters
itemTThe element to remove.
Returns
- bool
true if the element was successfully found and removed; otherwise, false.
RemoveWhere(Predicate<T>)
Removes all elements that match the conditions defined by the specified predicate. Raises the OnElementRemove event for each removed element.
public int RemoveWhere(Predicate<T> match)
Parameters
matchPredicate<T>The predicate that defines the conditions of the elements to remove.
Returns
- int
The number of elements removed from the set.
SetEquals(IEnumerable<T>)
public bool SetEquals(IEnumerable<T> other)
Parameters
otherIEnumerable<T>
Returns
SymmetricExceptWith(IEnumerable<T>)
Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both. Raises the OnElementAdd and OnElementRemove events as appropriate.
public void SymmetricExceptWith(IEnumerable<T> other)
Parameters
otherIEnumerable<T>The collection to compare to the current set.
UnionWith(IEnumerable<T>)
Modifies the current set so that it contains all elements that are present in the current set, in the specified collection, or in both. Raises the OnElementAdd event for each newly added element.
public void UnionWith(IEnumerable<T> other)
Parameters
otherIEnumerable<T>The collection to compare to the current set.
Events
OnElementAdd
Occurs when an element is added to the set.
public event Action<T> OnElementAdd
Event Type
- Action<T>
OnElementRemove
Occurs when an element is removed from the set.
public event Action<T> OnElementRemove
Event Type
- Action<T>