SystemEX  Lacking
Additional generic collection types missing in .net
SystemEx.Hash.BernsteinHash Class Reference
Inheritance diagram for SystemEx.Hash.BernsteinHash:
Collaboration diagram for SystemEx.Hash.BernsteinHash:

Public Member Functions

 BernsteinHash (Endian endian)
 Craate a new instance.
Hash32 Compute (FixedVector< byte > input, uint seed)
 Computes a simple 32‑bit hash from the given byte sequence.
Hash64 ComputeLong (FixedVector< byte > input, ulong seed)
 Computes a simple 64‑bit hash from the given byte sequence.

Constructor & Destructor Documentation

◆ BernsteinHash()

SystemEx.Hash.BernsteinHash.BernsteinHash ( Endian endian)

Craate a new instance.

Parameters
endianThe suing endian for creating a hash
50 {
51 m_endian = endian;
52 }

Member Function Documentation

◆ Compute()

Hash32 SystemEx.Hash.BernsteinHash.Compute ( FixedVector< byte > input,
uint seed )

Computes a simple 32‑bit hash from the given byte sequence.

The hash starts with the provided seed and mixes each byte using a small multiplier (31), similar to traditional Bernstein/DJB hash variants.

Endian does not affect this algorithm directly; it is included for interface compatibility with other SystemEx hashers.

Parameters
inputThe input data to hash.
seedThe seed value for the hash computation.
Returns
The computed Bernstein hash as a Hash32 object.

Implements SystemEx.Hash.IHash.

66 {
67 if ( input.Count == 0 )
68 return new Hash32(0);
69
70 uint hash = seed == 0 ? Default : seed;
71
72 // Simple deterministic byte loop
73 for ( int i = 0 ; i < input.Count ; i++ ) {
74 hash = (hash * 33) + input[i];
75 }
76 hash ^= (hash >> 16);
77 return new Hash32(hash);
78 }
long Count
Gets the number of valid elements currently stored in the vector.
Definition FixedVector.cs:71

◆ ComputeLong()

Hash64 SystemEx.Hash.BernsteinHash.ComputeLong ( FixedVector< byte > input,
ulong seed )

Computes a simple 64‑bit hash from the given byte sequence.

The hash starts with the provided seed and mixes each byte using a larger multiplier (1315423911), a common constant used in JSHash‑style Bernstein derivatives to improve diffusion in 64‑bit space.

Endian does not affect this algorithm directly; it is included for interface compatibility with other SystemEx hashers.

Parameters
inputThe input data to hash.
seedThe seed value for the hash computation.
Returns
The computed Bernstein hash as a Hash64 object.

Implements SystemEx.Hash.IHash.

93 {
94 if ( input.Count == 0 )
95 return new Hash64(0);
96
97 ulong hash = seed == 0 ? Default64 : seed;
98
99 // Larger multiplier for 64‑bit
100 for ( int i = 0 ; i < input.Count ; i++ ) {
101 hash = (hash * 1315423911L) + input[i];
102 }
103 hash ^= (hash >> 32);
104 return new Hash64(hash);
105 }

The documentation for this class was generated from the following file:
  • BernsteinHash.cs