Class EquatableSet<T>
Represents a strongly typed set of objects. Provides methods to manipulate the set. Also provides functionality to compare sets against each other through an implementations of System.IEquatable<T>, or to wrap an existing set to use the same comparison logic as this one while not affecting any of its other functionality.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Support
Assembly: Lucene.Net.dll
Syntax
public class EquatableSet<T> : ISet<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IEquatable<ISet<T>>
Type Parameters
| Name | Description |
|---|---|
| T | The type of elements in the list. |
Constructors
| Improve this Doc View SourceEquatableSet()
Initializes a new instance of the EquatableSet<T> class that is empty and has the default initial capacity.
Declaration
public EquatableSet()
EquatableSet(ICollection<T>)
Initializes a new instance of the EquatableSet<T> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
Declaration
public EquatableSet(ICollection<T> collection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.ICollection<T> | collection | The collection whose elements are copied to the new set. |
EquatableSet(IEnumerable<T>, IEqualityComparer<T>)
Initializes a new instance of the EquatableSet<T> class that uses the specified equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.
Declaration
public EquatableSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | collection | The collection whose elements are copied to the new set. |
| System.Collections.Generic.IEqualityComparer<T> | comparer | The System.Collections.Generic.IEqualityComparer<T> implementation to use
when comparing values in the set, or |
EquatableSet(IEqualityComparer<T>)
Initializes a new instance of the EquatableSet<T> class that is empty and uses the specified equality comparer for the set type.
Declaration
public EquatableSet(IEqualityComparer<T> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEqualityComparer<T> | comparer | The System.Collections.Generic.IEqualityComparer<T> implementation to use when comparing values in the set, or null to use the default System.Collections.Generic.EqualityComparer`1 implementation for the set type. |
EquatableSet(ISet<T>, Boolean)
Initializes a new instance of EquatableSet<T>.
If the wrap parameter is true, the
collection is used as is without doing
a copy operation. Otherwise, the collection is copied
(which is the same operation as the
EquatableSet(ICollection<T>) overload).
The internal collection is used for
all operations except for Equals(Object), GetHashCode(),
and ToString(), which are all based on deep analysis
of this collection and any nested collections.
Declaration
public EquatableSet(ISet<T> collection, bool wrap)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.ISet<T> | collection | The collection that will either be wrapped or copied
depending on the value of |
| System.Boolean | wrap |
|
Properties
| Improve this Doc View SourceCount
Gets the number of elements contained in the EquatableSet<T>.
Declaration
public virtual int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
IsReadOnly
Gets a value indicating whether the EquatableSet<T> is read-only.
Declaration
public virtual bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
| Improve this Doc View SourceAdd(T)
Adds an element to the current set and returns a value to indicate if the element was successfully added.
Declaration
public virtual bool Add(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The element to add to the set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Clear()
Removes all items from the EquatableSet<T>.
Declaration
public virtual void Clear()
Clone()
Clones the EquatableSet<T>.
Declaration
public virtual object Clone()
Returns
| Type | Description |
|---|---|
| System.Object | A new shallow clone of this EquatableSet<T>. |
Remarks
This is a shallow clone.
Contains(T)
Determines whether the EquatableSet<T> contains a specific value.
Declaration
public virtual bool Contains(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to locate in the EquatableSet<T>. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
CopyTo(T[], Int32)
Copies the elements of the EquatableSet<T> to an System.Array, starting at a particular System.Array index.
Declaration
public virtual void CopyTo(T[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | The one-dimensional System.Array that is the destination of the elements copied from EquatableSet<T>. The System.Array must have zero-based indexing. |
| System.Int32 | arrayIndex | The zero-based index in array at which copying begins. |
Equals(ISet<T>)
Compares this sequence to other, returning true if they
are equal, false otherwise.
The comparison takes into consideration any values in this collection and values of any nested collections, but does not take into consideration the data type. Therefore, EquatableSet<T> can equal any System.Collections.Generic.ISet<T> with the exact same values (in any order).
Declaration
public virtual bool Equals(ISet<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.ISet<T> | other | The other object to compare against. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Equals(Object)
If the object passed implements System.Collections.Generic.IList<T>,
compares this sequence to other, returning true if they
are equal, false otherwise.
The comparison takes into consideration any values in this collection and values of any nested collections, but does not take into consideration the data type. Therefore, EquatableSet<T> can equal any System.Collections.Generic.ISet<T> with the exact same values (in any order).
Declaration
public override bool Equals(object other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | other | The other object to compare against. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overrides
ExceptWith(IEnumerable<T>)
Removes all elements in the specified collection from the current set.
Declaration
public virtual void ExceptWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection of items to remove from the set. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public virtual IEnumerator<T> GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<T> | An enumerator that can be used to iterate through the collection. |
GetHashCode()
Returns the hash code value for this list.
The hash code determination takes into consideration any values in this collection and values of any nested collections, but does not take into consideration the data type. Therefore, the hash codes will be exactly the same for this EquatableSet<T> and another System.Collections.Generic.ISet<T> with the same values (in any order).
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | the hash code value for this list |
Overrides
IntersectWith(IEnumerable<T>)
Modifies the current set so that it contains only elements that are also in a specified collection.
Declaration
public virtual void IntersectWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
IsProperSubsetOf(IEnumerable<T>)
Determines whether the current set is a proper (strict) subset of a specified collection.
Declaration
public virtual bool IsProperSubsetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsProperSupersetOf(IEnumerable<T>)
Determines whether the current set is a proper (strict) superset of a specified collection.
Declaration
public virtual bool IsProperSupersetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsSubsetOf(IEnumerable<T>)
Determines whether a set is a subset of a specified collection.
Declaration
public virtual bool IsSubsetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsSupersetOf(IEnumerable<T>)
Determines whether the current set is a superset of a specified collection.
Declaration
public virtual bool IsSupersetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overlaps(IEnumerable<T>)
Determines whether the current set overlaps with the specified collection.
Declaration
public virtual bool Overlaps(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Remove(T)
Removes the first occurrence of a specific object from the EquatableSet<T>.
Declaration
public virtual bool Remove(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to remove from the EquatableSet<T>. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
SetEquals(IEnumerable<T>)
Determines whether the current set and the specified collection contain the same elements.
Declaration
public virtual bool SetEquals(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
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.
Declaration
public virtual void SymmetricExceptWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
ToString()
Returns a string representation of this collection (and any nested collections). The string representation consists of a list of the collection's elements in the order they are returned by its enumerator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | a string representation of this collection |
Overrides
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.
Declaration
public virtual void UnionWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current set. |
Explicit Interface Implementations
| Improve this Doc View SourceICollection<T>.Add(T)
Declaration
void ICollection<T>.Add(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator |