Class ExpressionSlimHasher
Base class for expression tree hash code computations.
Namespace: System.Linq.Expressions
Assembly: Nuqleon.Linq.Expressions.Bonsai.Hashing.dll
Syntax
public class ExpressionSlimHasher : Object
Constructors
ExpressionSlimHasher()
Creates a new expression hasher.
Declaration
public ExpressionSlimHasher()
ExpressionSlimHasher(Int32, IMemoizationCacheFactory)
Creates a new expression hasher with the specified object pool capacity and memoization cache factory.
Declaration
public ExpressionSlimHasher(int poolCapacity, IMemoizationCacheFactory cacheFactory)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | poolCapacity | The size of the internal object pool to keep data structures that are required to compute a hash code. |
IMemoizationCacheFactory | cacheFactory |
Remarks
The poolCapacity
parameter can be used to adjust the internal pool size when it's known that the
hasher is used in specific configurations. For example, if the hasher is only used from a single thread, a pool size
of 1
could suffice. In case one expects the overridden GetHashCode(ObjectSlim) method to reenter
the hasher, the pool size could be adjusted to allow for such reentrancy. If possible, it is recommended to make such
overridden GetHashCode(ObjectSlim) implementations call GetHashCode(ExpressionSlim) directly
rather than causing the creation of a new hasher instance.
Note that a pool size that's too small does not cause a functional regression; it merely can result in degraded hashing performance due to the allocation of internal data structures that cannot be reused.
Methods
GetHashCode(ExpressionSlim)
Gets a hash code for the specified expression
.
Declaration
public int GetHashCode(ExpressionSlim expression)
Parameters
Type | Name | Description |
---|---|---|
ExpressionSlim | expression | The expression tree to compute a hash code for. |
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the specified |
GetHashCode(LabelTargetSlim)
Gets the hash code for a label
.
Declaration
protected virtual int GetHashCode(LabelTargetSlim label)
Parameters
Type | Name | Description |
---|---|---|
LabelTargetSlim | label | The label to get the hash code for. |
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the specified global |
Remarks
The type of the label target (see Type will be added to the hash code returned by the overridden method. It is recommended to base the hash code of a label either on object identity or the name. The default implementation uses the name.
GetHashCode(ParameterExpressionSlim)
Gets the hash code for a global parameter
.
Declaration
protected virtual int GetHashCode(ParameterExpressionSlim parameter)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpressionSlim | parameter | The global parameter to get the hash code for. |
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the specified global |
Remarks
The expression type (System.Linq.Expressions.ExpressionType.Parameter) and the type of the expression (see Type will be added to the hash code returned by the overridden method. It is recommended to base the hash code of a global parameter either on object identity or the name. The default implementation uses the name.
GetHashCode(ObjectSlim)
Gets the hash code for the specified object value
.
Declaration
protected virtual int GetHashCode(ObjectSlim value)
Parameters
Type | Name | Description |
---|---|---|
System.ObjectSlim | value | The object value to get the hash code for. |
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the specified object |
GetHashCode(AssemblySlim)
Gets the hash code for the specified assembly
.
Declaration
protected virtual int GetHashCode(AssemblySlim assembly)
Parameters
Type | Name | Description |
---|---|---|
AssemblySlim | assembly | The assembly to get the hash code for. |
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the specified |
GetHashCode(String)
Gets the hash code for the specified string value
.
Declaration
protected virtual int GetHashCode(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to get the hash code for. |
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the specified string |