Esempio n. 1
0
        /// <summary>
        /// Add DNA Position
        /// </summary>
        /// <param name="key">DNA Value</param>
        /// <param name="x">X Posion</param>
        /// <param name="y">Y Posion</param>
        public void Add(string key, int x, int y)
        {
            //if (Count > _bucket.Length)
            //{
            //    Resize(Count + 10);
            //}
            var hashcode = GetHashCode(key, HASHSEED);
            var index    = GetIndex(hashcode);

            for (var i = _bucket[index]; i != null; i = i.Next)
            {
                if (i.Key == key && i.HashCode == hashcode)
                {
                    i.Add(x, y);
                    return;
                }
            }
            var length = 0;

            if (key.Length > 10)
            {
                length = 200;
            }
            else
            {
                length = (100 - key.Length) * 1000000 / ((int)Math.Pow(4, key.Length));
            }

            var e = _bucket[index];

            _bucket[index] = new DNAEntry(key, hashcode, length, e);
            _bucket[index].Add(x, y);
            Count++;
        }
Esempio n. 2
0
 public DNAEntry(string key, uint hashCode, int length, DNAEntry next)
 {
     Key       = key;
     HashCode  = hashCode;
     Positions = new DNAPos[length];
     Count     = 0;
     Next      = next;
 }