| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // System.Collections.CaseInsensitiveHashCodeProvider
- //
- // Author:
- // Sergey Chaban ([email protected])
- //
- using System;
- using System.Collections;
- namespace System.Collections {
- [Serializable]
- public class CaseInsensitiveHashCodeProvider : IHashCodeProvider {
- private static CaseInsensitiveHashCodeProvider singleton;
- // Class constructor
- static CaseInsensitiveHashCodeProvider ()
- {
- singleton=new CaseInsensitiveHashCodeProvider ();
- }
- // Public instance constructor
- public CaseInsensitiveHashCodeProvider ()
- {
- }
- //
- // Public static properties
- //
- public static CaseInsensitiveHashCodeProvider Default {
- get {
- return singleton;
- }
- }
- //
- // Instance methods
- //
- //
- // IHashCodeProvider
- //
- [MonoTODO]
- public int GetHashCode (object obj)
- {
- if (obj == null) {
- throw new ArgumentNullException ("obj is null");
- }
- string str = obj as string;
- if (str == null) {
- // FIXME:
- return 0;
- }
- int h = 0;
- char c;
- if (str.Length > 0) {
- for (int i = 0;i<str.Length;i++) {
- c = str [i];
- if (Char.IsLetter (c))
- c = Char.ToLower (c);
- h = h * 31 + c;
- }
- }
- return h;
- }
- } // CaseInsensitiveHashCodeProvider
- }
|