Table of Contents

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

T

The type of elements in the set.

Inheritance
BindableHashSet<T>
Implements
ISet<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

collection IEnumerable<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

collection IEnumerable<T>

The collection whose elements are copied to the new set.

comparer IEqualityComparer<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

comparer IEqualityComparer<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

IBindable<int>

Comparer

Gets the equality comparer used to determine equality for the values in the set.

public IEqualityComparer<T> Comparer { get; }

Property Value

IEqualityComparer<T>

Count

public int Count { get; }

Property Value

int

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

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

item T

The 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

item T

Returns

bool

CopyTo(T[])

Copies the elements of the set to an array.

public void CopyTo(T[] array)

Parameters

array T[]

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

array T[]
arrayIndex int

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

array T[]

The one-dimensional array that is the destination of the elements copied from the set.

arrayIndex int

The zero-based index in array at which copying begins.

count int

The 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

other IEnumerable<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

info SerializationInfo
context StreamingContext

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

other IEnumerable<T>

The collection to compare to the current set.

IsProperSubsetOf(IEnumerable<T>)

public bool IsProperSubsetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

Returns

bool

IsProperSupersetOf(IEnumerable<T>)

public bool IsProperSupersetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

Returns

bool

IsSubsetOf(IEnumerable<T>)

public bool IsSubsetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

Returns

bool

IsSupersetOf(IEnumerable<T>)

public bool IsSupersetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

Returns

bool

OnDeserialization(object)

public void OnDeserialization(object sender)

Parameters

sender object

Overlaps(IEnumerable<T>)

public bool Overlaps(IEnumerable<T> other)

Parameters

other IEnumerable<T>

Returns

bool

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

item T

The 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

match Predicate<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

other IEnumerable<T>

Returns

bool

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

other IEnumerable<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

other IEnumerable<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>