Пример #1
0
        // Visited dictionary to hold old node reference as "key" and new node reference as the "value"
        public SLLNode GetClonedNode(Dictionary <SLLNode, SLLNode> originalToClonedDict, SLLNode node)
        {
            // If the node exists then
            if (node == null)
            {
                return(null);
            }

            // Check if the node is in the visited dictionary
            if (!originalToClonedDict.ContainsKey(node))
            {
                // Otherwise create a new node, add to the dictionary and return it
                originalToClonedDict.Add(node, new SLLNode(node.value));
            }

            // If its in the visited dictionary then return the new node
            // reference from the dictionary

            return(originalToClonedDict[node]);
        }
Пример #2
0
 public SLLNode(int value)
 {
     Value = value;
     Next  = null;
 }
Пример #3
0
 public SLLNode(int d)
 {
     data = d;
     next = null;
 }
Пример #4
0
 public SLLNode(T value)
 {
     this.Value = value;
     this.Next  = null;
 }
Пример #5
0
 public SLList()
 {
     this.head = null;
     this.tail = null;
 }
Пример #6
0
 public SLLNode(int nodeData)
 {
     this.data = nodeData;
     this.next = null;
 }