Exemplo n.º 1
0
 public bool TryGetNode(TK key, out ValueNode <TK> node)
 {
     return(_chidNodesDictionary.TryGetValue(key, out node));
 }
Exemplo n.º 2
0
        public bool TryGetNode(IEnumerable <TK> keysList, out ValueNode <TK> node)
        {
            ValueNodeInternal <TK> parentNode;

            return(TrySeparateKeysList(keysList, out parentNode, out node));
        }
Exemplo n.º 3
0
        //private ValueTreeInternalNode(K key, ValueTreeInternalNode<K> src_node)
        //    : base(key)
        //{
        //    foreach (var pair in src_node._ChidNodesDictionary)
        //        _ChidNodesDictionary.Add(pair.Key, pair.Value);
        //}


        public bool TrySeparateKeysList(IEnumerable <TK> keysList, out ValueNodeInternal <TK> parentNode, out ValueNode <TK> childNode)
        {
            childNode  = null;
            parentNode = this;

            foreach (var key in keysList)
            {
                if (childNode != null)
                {
                    if (childNode.IsInternalNode)
                    {
                        parentNode = (ValueNodeInternal <TK>)childNode;
                    }
                    else
                    {
                        parentNode = null;
                        childNode  = null;
                        return(false);
                    }
                }

                if (parentNode._chidNodesDictionary.TryGetValue(key, out childNode))
                {
                    continue;
                }

                parentNode = null;
                return(false);
            }

            if (childNode != null)
            {
                return(true);
            }

            parentNode = null;
            return(false);
        }