Class Equatable
A set of utilities uses for easily wrapping .NET
collections so they can be used with System.Object.Equals(System.Object)
System.Object.GetHashCode(), and System.Object.ToString()
behavior similar to that in Java. The equality checking of collections
will recursively compare the values of all elements and any nested collections.
The same goes for using System.Object.ToString() - the string is based
on the values in the collection and any nested collections.
Do note this has a side-effect that any custom System.Object.Equals(System.Object)
System.Object.GetHashCode(), and System.Object.ToString() implementations
for types that implement System.Collections.Generic.IList<T> (including arrays), System.Collections.Generic.ISet<T>,
or System.Collections.Generic.IDictionary<TKey, TValue> will be ignored.
Inheritance
System.Object
Equatable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Lucene.Net.dll
Syntax
public static class Equatable
Methods
|
Improve this Doc
View Source
Wrap<T>(IList<T>)
Wraps any System.Collections.Generic.IList<T> (including T[]) with a
lightweight EquatableList<T> class that changes the behavior
of System.Object.Equals(System.Object)
System.Object.GetHashCode(), and System.Object.ToString()
so they consider all values in the System.Collections.Generic.IList<T> or any nested
collections when comparing or making strings to represent them.
No other behavior is changed - only these 3 methods.
Note that if the list is already an EquatableList<T> or a subclass
of it, this method simply returns the provided list
.
Declaration
public static IList<T> Wrap<T>(IList<T> list)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
list |
Any System.Collections.Generic.IList<T> (including T[])
|
Returns
Type |
Description |
System.Collections.Generic.IList<T> |
An EquatableList<T> that wraps the provided list ,
or the value of list unmodified if it already is an EquatableList<T>
|
Type Parameters
Name |
Description |
T |
the type of element
|
|
Improve this Doc
View Source
Wrap<T>(ISet<T>)
Wraps any System.Collections.Generic.ISet<T> with a
lightweight EquatableSet<T> class that changes the behavior
of System.Object.Equals(System.Object)
System.Object.GetHashCode(), and System.Object.ToString()
so they consider all values in the System.Collections.Generic.ISet<T> or any nested
collections when comparing or making strings to represent them.
No other behavior is changed - only these 3 methods.
Note that if the set is already an EquatableSet<T> or a subclass
of it, this method simply returns the provided set
.
Declaration
public static ISet<T> Wrap<T>(ISet<T> set)
Parameters
Type |
Name |
Description |
System.Collections.Generic.ISet<T> |
set |
Any System.Collections.Generic.IList<T> (including T[])
|
Returns
Type |
Description |
System.Collections.Generic.ISet<T> |
An EquatableSet<T> that wraps the provided set ,
or the value of set unmodified if it already is an EquatableSet<T>
|
Type Parameters
Name |
Description |
T |
the type of element
|