public override int GetHashCode() { ulong seed = Marvin.DefaultSeed; // Multiplication below will not overflow since going from positive Int32 to UInt32. return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), (uint)_stringLength * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32))); }
public static int GetHashCode(ReadOnlySpan <char> value) { ulong seed = Marvin.DefaultSeed; // Multiplication below will not overflow since going from positive Int32 to UInt32. return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref MemoryMarshal.GetReference(value)), (uint)value.Length * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32))); }
// Gets a hash code for this string. If strings A and B are such that A.Equals(B), then // they will return the same hash code. public override int GetHashCode() { #if MONO return(LegacyStringGetHashCode()); #else return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), _stringLength * 2, Marvin.DefaultSeed)); #endif }
/// <summary> /// Returns a hash code using a <see cref="StringComparison.Ordinal"/> comparison. /// </summary> public override int GetHashCode() { // TODO_UTF8STRING: Consider whether this should use a different seed than String.GetHashCode. ulong seed = Marvin.DefaultSeed; return(Marvin.ComputeHash32(ref DangerousGetMutableReference(), (uint)_length /* in bytes */, (uint)seed, (uint)(seed >> 32))); }
// Gets a hash code for this string. If strings A and B are such that A.Equals(B), then // they will return the same hash code. public override int GetHashCode() { return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), _stringLength * 2, Marvin.DefaultSeed)); }
public static int GetHashCode(ReadOnlySpan <char> value) { ulong seed = Marvin.DefaultSeed; return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref MemoryMarshal.GetReference(value)), value.Length * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32))); }
public override int GetHashCode() { ulong seed = Marvin.DefaultSeed; return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), _stringLength * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32))); }