コード例 #1
0
        public LPoint SearchPerson(string searchedPerson)
        {
            var point      = new LPoint(searchedPerson);
            var index      = point.GetHashCode() % Size;
            var firstIndex = index;

            while (Table[index] != null)
            {
                if (Table[index].ToString().Contains(searchedPerson))
                {
                    return(Table[index]);
                }
                else
                {
                    index++;
                    if (index >= Table.Length)
                    {
                        index = 0;
                    }
                    if (index == firstIndex)
                    {
                        break;
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        public bool Add(string key, string s, out int count, out bool flag, out int size)
        {
            flag = true;
            var keyIndex = new LPoint(key);
            var point    = new LPoint(s);

            size  = Table.Length;
            count = 0;
            if (s == null)
            {
                return(false);
            }
            var index = keyIndex.GetHashCode() % Size;

            if (Table[index] == null)
            {
                Table[index] = point;
            }
            else
            {
                count++;
                var firstIndex = index;
                while (Table[index] != null)
                {
                    index++;
                    if (index >= Table.Length)
                    {
                        index = 0;
                    }
                    if (index == firstIndex)
                    {
                        size = Table.Length + 1;
                        flag = false;
                        break;
                    }
                }

                Table[index] = point;
            }

            return(true);
        }