Table of Contents

Struct Hash

Namespace
LfrlAnvil
Assembly
LfrlAnvil.Core.dll

Represents a lightweight hash code computation result.

public readonly struct Hash : IEquatable<Hash>, IComparable<Hash>, IComparable
Implements
Inherited Members
Extension Methods

Constructors

Hash(int)

Creates a new Hash instance.

public Hash(int value)

Parameters

value int

Underlying hash code value.

Fields

Default

Represents a default hash code computation, equivalent to 0.

public static readonly Hash Default

Field Value

Hash

Value

Underlying hash code value.

public readonly int Value

Field Value

int

Methods

AddRange<T>(IEnumerable<T?>)

Creates a new Hash instance by calculating hash codes of all objects provided in the range and including them in the hash code of this instance.

[Pure]
public Hash AddRange<T>(IEnumerable<T?> range)

Parameters

range IEnumerable<T>

Range of objects to add.

Returns

Hash

New Hash instance.

Type Parameters

T

Element type.

AddRange<T>(params T?[])

Creates a new Hash instance by calculating hash codes of all objects provided in the range and including them in the hash code of this instance.

[Pure]
public Hash AddRange<T>(params T?[] range)

Parameters

range T[]

Range of objects to add.

Returns

Hash

New Hash instance.

Type Parameters

T

Element type.

Add<T>(T?)

Creates a new Hash instance by calculating a hash code of the provided obj and including it in the hash code of this instance.

[Pure]
public Hash Add<T>(T? obj)

Parameters

obj T

Object to add.

Returns

Hash

New Hash instance.

Type Parameters

T

Value type.

CompareTo(Hash)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

[Pure]
public int CompareTo(Hash other)

Parameters

other Hash

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(object?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

[Pure]
public int CompareTo(object? obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

Equals(Hash)

Indicates whether the current object is equal to another object of the same type.

[Pure]
public bool Equals(Hash other)

Parameters

other Hash

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

[Pure]
public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

[Pure]
public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns a string representation of this Hash instance.

[Pure]
public override string ToString()

Returns

string

String representation.

Operators

operator ==(Hash, Hash)

Checks if a is equal to b.

[Pure]
public static bool operator ==(Hash a, Hash b)

Parameters

a Hash

First operand.

b Hash

Second operand.

Returns

bool

true when operands are equal, otherwise false.

operator >(Hash, Hash)

Checks if a is greater than b.

[Pure]
public static bool operator >(Hash a, Hash b)

Parameters

a Hash

First operand.

b Hash

Second operand.

Returns

bool

true when a is greater than b, otherwise false.

operator >=(Hash, Hash)

Checks if a is greater than or equal to b.

[Pure]
public static bool operator >=(Hash a, Hash b)

Parameters

a Hash

First operand.

b Hash

Second operand.

Returns

bool

true when a is greater than or equal to b, otherwise false.

implicit operator int(Hash)

Returns the underlying Value from the provided h.

[Pure]
public static implicit operator int(Hash h)

Parameters

h Hash

Object to convert.

Returns

int

Underlying Value from the provided h.

operator !=(Hash, Hash)

Checks if a is not equal to b.

[Pure]
public static bool operator !=(Hash a, Hash b)

Parameters

a Hash

First operand.

b Hash

Second operand.

Returns

bool

true when operands are not equal, otherwise false.

operator <(Hash, Hash)

Checks if a is less than b.

[Pure]
public static bool operator <(Hash a, Hash b)

Parameters

a Hash

First operand.

b Hash

Second operand.

Returns

bool

true when a is less than b, otherwise false.

operator <=(Hash, Hash)

Checks if a is less than or equal to b.

[Pure]
public static bool operator <=(Hash a, Hash b)

Parameters

a Hash

First operand.

b Hash

Second operand.

Returns

bool

true when a is less than or equal to b, otherwise false.