예제 #1
0
 private SLNode Add(SLNode node, int data)
 {
     if (node == null)
     {
         return(new SLNode(data));
     }
     node.Next = Add(node.Next, data);
     return(node);
 }
예제 #2
0
        static bool RemoveNode(SLNode node)
        {
            if (node == null || node.Next == null)
            {
                return(false);
            }
            SLNode next = node.Next;

            node.Data = next.Data;
            node.Next = next.Next;
            return(true);
        }
예제 #3
0
        static public int[] ToArray(SLNode node)
        {
            SLNode     curr = node;
            List <int> l    = new List <int>();

            while (curr != null)
            {
                l.Add(curr.Data);
                curr = curr.Next;
            }
            return(l.ToArray());
        }
예제 #4
0
 private SLNode FindNode(SLNode node, int data)
 {
     if (node == null)
     {
         return(null);
     }
     if (node.Data == data)
     {
         return(node);
     }
     else
     {
         return(FindNode(node.Next, data));
     }
 }
예제 #5
0
 public void Add(int data)
 {
     root = Add(root, data);
 }