コード例 #1
0
 protected virtual IEnumerable <TValue> SearchDeep(string query, int position, bool isCaseSensitive)
 {
     if (!isCaseSensitive)
     {
         TrieNodeBase <TValue> nextNode = GetChildOrNull(query.ToLower(), position);
         return(nextNode != null
             ? nextNode.Retrieve(query.ToLower(), position + nextNode.KeyLength, isCaseSensitive)
             : Enumerable.Empty <TValue>());
     }
     else
     {
         TrieNodeBase <TValue> nextNode = GetChildOrNull(query, position);
         return(nextNode != null
             ? nextNode.Retrieve(query, position + nextNode.KeyLength, isCaseSensitive)
             : Enumerable.Empty <TValue>());
     }
 }
コード例 #2
0
        public void Add(string key, int position, TValue value, bool isCaseSensitive)
        {
            if (!isCaseSensitive)
            {
                key = key.ToLower();
            }

            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (EndOfString(position, key))
            {
                AddValue(value);
                return;
            }

            TrieNodeBase <TValue> child = GetOrCreateChild(key[position]);

            child.Add(key, position + 1, value, isCaseSensitive);
        }