Пример #1
0
 public void Append(int DataValue)
 {
     ListNode NewNode = new ListNode(DataValue);
     if (IsNull())//如果头指针为空
     {
         Head = NewNode;
         Tail = NewNode;
     }
     else
     {
         Tail.Next = NewNode;
         NewNode.Previous = Tail;
         Tail = NewNode;
     } Current = NewNode;
     ListCountValue += 1; //链表数据个数加1
 }
Пример #2
0
 public void Delete()
 {
     if (!IsNull())//若为空链表
     {
         if (IsBof())//若删除头
         {
             Head = Current.Next;
             Current = Head; ListCountValue -= 1;
             return;
         } if (IsEof())//若删除尾
         {
             Tail = Current.Previous; Current = Tail;
             ListCountValue -= 1; return;
         }
         Current.Previous.Next = Current.Next; //若删除中间数据
         Current = Current.Previous; ListCountValue -= 1;
         return;
     }
 }
Пример #3
0
 public void Insert(int DataValue)
 {
     ListNode NewNode = new ListNode(DataValue);
     if (IsNull())
     {
         Append(DataValue); //为空表,则添加
         return;
     } if (IsBof())
     {           //为头部插入
         NewNode.Next = Head; Head.Previous = NewNode; Head = NewNode;
         Current = Head; ListCountValue += 1; return;
     }       //中间插入
     NewNode.Next = Current; NewNode.Previous = Current.Previous; Current.Previous.Next = NewNode;
     Current.Previous = NewNode; Current = NewNode;
     ListCountValue += 1;
 }
Пример #4
0
        private ListNode Tail; //尾指针

        #endregion Fields

        #region Constructors

        //构造函数
        public CList()
        {
            ListCountValue = 0; //初始化
            Head = null; Tail = null;
        }
Пример #5
0
 public void MovePrevious()
 {
     if (!IsBof()) Current = Current.Previous;
 }
Пример #6
0
 //向后移动一个数据
 public void MoveNext()
 {
     if (!IsEof()) Current = Current.Next;
 }
Пример #7
0
 public void MoveLast()
 {
     Current = Tail;
 }
Пример #8
0
 public void MoveFrist()
 {
     Current = Head;
 }