示例#1
0
        /// <summary>
        /// Dictionary.TryGetValue(string)
        /// </summary>
        internal int FindString(string name)
        {
            if (m_map == null)
            {
                FixedHashTable map = new FixedHashTable(m_size);

                for (int i = 0; i < m_size; i++)
                {
                    map.Add(GetStringHash(i), i);
                }

                m_map = map;
            }

            int hash = StringPool.StableStringHash(name);

            // Search hash table
            for (int slot = m_map.GetFirst(hash); slot >= 0; slot = m_map.GetNext(slot))
            {
                int index = m_map.GetIndex(slot);

                if (IsStringEqual(name, index))
                {
                    return(index);
                }
            }

            return(-1);
        }
示例#2
0
 internal override int GetStringHash(int i)
 {
     return(m_pool.StableStringHash(m_indices[i]));
 }