Esempio n. 1
0
        /// <summary>Gets the atomized string containing the same characters as the specified range of characters in the given array.</summary>
        /// <returns>The atomized string or null if the string has not already been atomized. If <paramref name="len" /> is zero, String.Empty is returned.</returns>
        /// <param name="key">The character array containing the name to find. </param>
        /// <param name="start">The zero-based index into the array specifying the first character of the name. </param>
        /// <param name="len">The number of characters in the name. </param>
        /// <exception cref="T:System.IndexOutOfRangeException">0 &gt; <paramref name="start" />-or- <paramref name="start" /> &gt;= <paramref name="key" />.Length -or- <paramref name="len" /> &gt;= <paramref name="key" />.Length The above conditions do not cause an exception to be thrown if <paramref name="len" /> =0. </exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="len" /> &lt; 0. </exception>
        public override string Get(char[] key, int start, int len)
        {
            if ((0 > start && start >= key.Length) || (0 > len && len >= key.Length - len))
            {
                throw new IndexOutOfRangeException("The Index is out of range.");
            }
            if (len == 0)
            {
                return(string.Empty);
            }
            int num  = 0;
            int num2 = start + len;

            for (int i = start; i < num2; i++)
            {
                num = (num << 5) - num + (int)key[i];
            }
            num &= int.MaxValue;
            for (NameTable.Entry entry = this.buckets[num % this.count]; entry != null; entry = entry.next)
            {
                if (entry.hash == num && entry.len == len && NameTable.StrEqArray(entry.str, key, start))
                {
                    return(entry.str);
                }
            }
            return(null);
        }