Exemple #1
0
 /// <summary>
 /// Adds the list to the end of the current list
 /// </summary>
 /// <param name="list"></param>
 public void AddRange(IndexedList <T> list)
 {
     foreach (IndexedWord <T> i in list._list)
     {
         _list.AddLast(i);
     }
 }
Exemple #2
0
        /// <summary>
        /// Uses yield return. Doesn't have any dupes, they've already been eliminated.
        /// </summary>
        /// <param name="word"></param>
        /// <returns></returns>
        private IEnumerable <T> getMatches(string word)
        {
            if (string.IsNullOrEmpty(word))
            {
                return(new T[0]);
            }

            //regular item
            if (word.Length >= 3)
            {
                int index = getIndex(word);

                IndexedList <T> f = _items[index];
                if (f == null)
                {
                    return(new T[0]);
                }

                return(EliminateDuplicates(f.GetMatches(word)));
            }

            //SHORT ITEM
            //get all the short matches

            var shortMatches = _shortItems.GetMatches(word);

            //now add all possibilities
            int start = getIndex(word);
            int end   = start;

            end += word.Length == 1 ? 1369 : 37;

            var allPossibilities = new EnumerableFromEnumerator <T>(new AllEnumerator(_items, start, end));

            var merged = shortMatches.Concat(allPossibilities);

            return(EliminateDuplicates(merged));
        }
Exemple #3
0
        private void put(IndexedWord <T> item)
        {
            //if short word
            if (item.Word.Length < 3)
            {
                _shortItems.Add(item);
            }

            //otherwise add in array
            else
            {
                int index = getIndex(item.Word);

                IndexedList <T> list = _items[index];

                if (list == null)
                {
                    list          = new IndexedList <T>();
                    _items[index] = list;
                }

                list.Add(item);
            }
        }