Пример #1
0
        /// <summary>Store the given value at the specified path.</summary>
        public virtual void AddPath(T value, params sbyte[][] parts)
        {
            int depth             = 0;
            ByteTrieNode <T> node = _root;

            foreach (sbyte[] part in parts)
            {
                foreach (sbyte b in part)
                {
                    ByteTrieNode <T> child = node._children.Get(b);
                    if (child == null)
                    {
                        child = new ByteTrieNode <T>();
                        node._children.Put(b, child);
                    }
                    node = child;
                    depth++;
                }
            }
            node.SetValue(value);
            _maxDepth = Math.Max(_maxDepth, depth);
        }
 /// <summary>
 /// Sets the default value to use in <see cref="ByteTrie{T}.Find(byte[])"/> when no path matches.
 /// </summary>
 public void SetDefaultValue(T defaultValue) => _root.SetValue(defaultValue);
Пример #3
0
 /// <summary>
 /// Sets the default value to use in
 /// <see cref="ByteTrie{T}.Find(sbyte[])"/>
 /// when no path matches.
 /// </summary>
 public virtual void SetDefaultValue(T defaultValue)
 {
     _root.SetValue(defaultValue);
 }