Example #1
0
 /// <summary>
 /// 打印链表中全部的数
 /// </summary>
 /// <param name="list">链表参数</param>
 public void ShowList(Creastlist list)
 {
     Console.WriteLine("当前链表中数据为:");
     list.MoveFrist();
     for (int i = 0; i < list.ListCount; i++)
     {
         Console.Write(list.GetCurrentValue() + "  ");
         list.MoveNext();
     }
 }
Example #2
0
        /// <summary>
        /// 构造一个初始化好的链表
        /// </summary>
        /// <param name="str">初始化的字符串,并以逗号或者空格隔开</param>
        public Creastlist(string str)
        {
            //构造函数
            //初始化
            char[]     separator = { ',', ' ' };
            string[]   s         = str.Split(separator);
            Creastlist list      = new Creastlist();

            foreach (string i in s)
            {
                int j = Convert.ToInt32(i);
                list.Append(j);
            }
            ListCountValue = s.Length;
            Tail           = list.Current;
            Head           = list.Head;
        }