示例#1
0
        static void Main(string[] args)
        {
            SinglyList <int> number = new SinglyList <int>();

            number.Add(5);
            number.Add(6);
            number.Add(3);
            number.Add(1);

            SinglyList <int> number1 = new SinglyList <int>(number);

            //Console.WriteLine(number.DeleteNode(3));
            //Console.WriteLine(number);
            //Console.WriteLine(number.Count);
            //Console.WriteLine(number.DeleteNode(2));
            //Console.WriteLine(number);
            //Console.WriteLine(number.Count);


            SinglyList <string> name = new SinglyList <string>();

            name.Add("Roma");
            name.Add(null);
            name.Add("Roma");
            name.Add("Stat");

            Console.WriteLine(name.DeleteNode(0));
            Console.WriteLine(name);
            Console.WriteLine(name.Count);
            Console.WriteLine(name.GetFirstValue());
            //Console.WriteLine(name.DeleteNode(2));
            //Console.WriteLine(name);
            //Console.WriteLine(name.Count);
            Console.ReadLine();
        }
示例#2
0
 public SinglyList(SinglyList <T> list)
 {
     if (list.Count == 0)
     {
         Head = null;
     }
     else
     {
         Head = new Node <T>(list.Head.Data);
         Node <T> newNode  = Head;
         Node <T> listNode = list.Head;
         while (listNode.Next != null)
         {
             listNode     = listNode.Next;
             newNode.Next = new Node <T>(listNode.Data);
             newNode      = newNode.Next;
         }
         Count = list.Count;
     }
 }