You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
57
mcs/class/referencesource/System/misc/CompatibleIComparer.cs
Normal file
57
mcs/class/referencesource/System/misc/CompatibleIComparer.cs
Normal file
@ -0,0 +1,57 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CompatibleComparer.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* This class is used to create hashcodes that are Everett Compatible.
|
||||
*
|
||||
* Copyright (c) 2004 Microsoft Corporation
|
||||
*/
|
||||
|
||||
namespace System.Collections.Specialized {
|
||||
|
||||
using Microsoft.Win32;
|
||||
using System.Collections;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Globalization;
|
||||
|
||||
internal class BackCompatibleStringComparer : IEqualityComparer {
|
||||
|
||||
static internal IEqualityComparer Default = new BackCompatibleStringComparer();
|
||||
|
||||
internal BackCompatibleStringComparer() {
|
||||
}
|
||||
|
||||
//This comes from VS# 434837 and is specifically written to get backcompat
|
||||
public static int GetHashCode(string obj) {
|
||||
unsafe {
|
||||
fixed (char* src = obj) {
|
||||
int hash = 5381;
|
||||
int c;
|
||||
char* szStr = src;
|
||||
|
||||
while ((c = *szStr) != 0) {
|
||||
hash = ((hash << 5) + hash) ^ c;
|
||||
++szStr;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IEqualityComparer.Equals(Object a, Object b) {
|
||||
return Object.Equals(a, b);
|
||||
}
|
||||
|
||||
public virtual int GetHashCode(Object o) {
|
||||
String obj = o as string;
|
||||
if (obj == null) {
|
||||
return o.GetHashCode();
|
||||
}
|
||||
|
||||
return BackCompatibleStringComparer.GetHashCode(obj);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user