Example #1
0
        private int getHashCode(CharSequence text)
        {
            int code;

            if (_ignoreCase)
            {
                code = 0;
                int len = text.length();
                for (int i = 0; i < len; i++)
                {
                    code = code * 31 + Character.toLowerCase(text.charAt(i));
                }
            }
            else
            {
#pragma warning disable 184
                if (false && text is string)
#pragma warning restore 184
                {
                    code = text.GetHashCode();
                }
                else
                {
                    code = 0;
                    int len = text.length();
                    for (int i = 0; i < len; i++)
                    {
                        code = code * 31 + text.charAt(i);
                    }
                }
            }
            return(code);
        }
Example #2
0
 private bool equals(char[] text1, int off, int len, char[] text2)
 {
     if (len != text2.Length)
     {
         return(false);
     }
     if (_ignoreCase)
     {
         for (int i = 0; i < len; i++)
         {
             if (Character.toLowerCase(text1[off + i]) != text2[i])
             {
                 return(false);
             }
         }
     }
     else
     {
         for (int i = 0; i < len; i++)
         {
             if (text1[off + i] != text2[i])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Example #3
0
        private bool equals(CharSequence text1, char[] text2)
        {
            int len = text1.length();

            if (len != text2.Length)
            {
                return(false);
            }
            if (_ignoreCase)
            {
                for (int i = 0; i < len; i++)
                {
                    if (Character.toLowerCase(text1.charAt(i)) != text2[i])
                    {
                        return(false);
                    }
                }
            }
            else
            {
                for (int i = 0; i < len; i++)
                {
                    if (text1.charAt(i) != text2[i])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #4
0
        /** Add this key,val pair to the map.
         * The char[] key is directly used, no copy is made.
         * If ignoreCase is true for this Map, the key array will be directly modified.
         * The user should never modify the key after calling this method.
         */
        public object put(char[] key, object val)
        {
            if (_ignoreCase)
            {
                for (int i = 0; i < key.Length; i++)
                {
                    key[i] = Character.toLowerCase(key[i]);
                }
            }
            int slot = getSlot(key, 0, key.Length);

            if (keys[slot] == null)
            {
                count++;
            }
            object prev = values[slot];

            keys[slot]   = key;
            values[slot] = val;

            if (count + (count >> 2) >= keys.Length)
            {
                rehash();
            }

            return(prev);
        }
Example #5
0
        private int getHashCode(char[] text, int len)
        {
            int code = 0;

            if (_ignoreCase)
            {
                for (int i = 0; i < len; i++)
                {
                    code = code * 31 + Character.toLowerCase(text[i]);
                }
            }
            else
            {
                for (int i = 0; i < len; i++)
                {
                    code = code * 31 + text[i];
                }
            }
            return(code);
        }