示例#1
0
 /// <summary>
 /// Private constructor. Classes should use the static helper methods
 /// to create a new Node in different scenarios
 /// </summary>
 private Node()
 {
     _hasValue     = false;
     _compositeKey = default(TKey);
     _nodeKey      = default(TSubKey);
     _value        = default(TValue);
     _children     = new List <Node>();
 }
示例#2
0
            /// <summary>
            /// Creates a new node that is associated with a key. A value can be assigned to this node
            /// using the AssignValue method
            /// </summary>
            public static Node Create(TSubKey nodeKey)
            {
                Node node = new Node();

                node._compositeKey = default(TKey);
                node._hasValue     = false;
                node._nodeKey      = nodeKey;
                node._value        = default(TValue);

                return(node);
            }
示例#3
0
 /// <summary>
 /// Tries to get a child node that matches the supplied key using the supplied
 /// comparer.  Returns null if a matching node cannot be found
 /// </summary>
 public Node GetChildForKey(TSubKey key, IEqualityComparer <TSubKey> subKeyComparer)
 {
     return(_children.FirstOrDefault(c => subKeyComparer.Equals(key, c.NodeKey)));
 }