/// <summary> /// Get hash code for sub string /// </summary> public static int GetHashCode(string s, int index, int length) { if (s == null) { throw new ArgumentNullException(nameof(s)); } if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index)); } if (((uint)index + (uint)length) > s.Length) { throw new ArgumentOutOfRangeException(nameof(length)); } unsafe { fixed(char *p = s) { return(FastStringComparer.FastGetHash(p + index, length)); } } }
/// <summary> /// Get Hash code for full string /// </summary> public static int GetHashCode(string s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } unsafe { fixed(char *p = s) { return(FastStringComparer.FastGetHash(p, s.Length)); } } }
/// <summary> /// Get Hash code for full byte array, return true for all ASCII /// </summary> public static int GetHashCode(byte[] s, out bool isAscii) { if (s == null) { throw new ArgumentNullException(nameof(s)); } unsafe { fixed(byte *p = s) { return(FastStringComparer.FastGetHash(p, s.Length, out isAscii)); } } }