Show / Hide Table of Contents

Class KnownSizeHasher

NON-GENERALIZED hashing algorithm for Point instances that calculates a hash, assuming points will fall between (0, 0) and some known maximum width.

Inheritance
Object
KnownSizeHasher
Namespace: SadRogue.Primitives.PointHashers
Assembly: TheSadRogue.Primitives.dll
Syntax
public class KnownSizeHasher : EqualityComparer<Point>
Remarks

This is NOT an efficient generalized hashing algorithm; it generates a hash code using the assumption that any points given to it fall between (0, 0) and the (width - 1, arbitrary_y). It simply uses the ToIndex(Int32) function to generate a hash. The algorithm WILL still function on points outside of the assumed bounds; however it will simply start to generate collisions.

This algorithm is nonetheless useful in some cases; the assumption that points will fall from (0, 0) to some known max x-value is fairly common (as it could apply to any fixed-size grid). Since this algorithm can be significantly faster to compute than fully generalized algorithms, it can be useful for these cases.

Constructors

KnownSizeHasher(Int32)

Creates a new instance of the comparison/hashing algorithm implementation.

Declaration
public KnownSizeHasher(int boundsWidth)
Parameters
Type Name Description
Int32 boundsWidth

The width of the area points are assumed to fall in. Points are assumed to fall between (0, 0) and (boundsWidth - 1). It WILL hash points outside this range, however doing so may generate collisions.

Fields

BoundsWidth

The width of the area points are assumed to fall in.

Declaration
public readonly int BoundsWidth
Field Value
Type Description
Int32

Methods

Equals(Point, Point)

Declaration
public override bool Equals(Point x, Point y)
Parameters
Type Name Description
Point x
Point y
Returns
Type Description
Boolean

GetHashCode(Point)

Declaration
public override int GetHashCode(Point p)
Parameters
Type Name Description
Point p
Returns
Type Description
Int32

Extension Methods

PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>)
PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>, EventHandler<ValueChangedEventArgs<TProperty>>)
In This Article
Back to top Generated by DocFX