Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public int GetOrCreateIndex(NativeStringView value)
        {
            int h         = value.GetHashCode();
            var itemIndex = GetIndex(h, value);

            if (itemIndex != -1)
            {
                return(itemIndex);
            }
            Assert.IsTrue(entries < kMaxEntries);
            Assert.IsTrue(chars + value.Length <= kMaxChars);
            var o = chars;
            var l = (ushort)value.Length;

            for (var i = 0; i < l; ++i)
            {
                buffer[chars++] = value[i];
            }
            offset[entries] = o;
            length[entries] = l;
            hash.Add(h, entries);
            return(entries++);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool Contains(NativeStringView value)
        {
            int h = value.GetHashCode();

            return(GetIndex(h, value) != -1);
        }