Example #1
0
    public void PushBefore(ViRefNode1 <T> after, ViRefList1 <T> list)
    {
        if (list.Size == 0)
        {
            return;
        }
        if (after.IsAttach(list))
        {
            return;
        }
        if (after.IsAttach() == false)
        {
            return;
        }
        ViDebuger.AssertError(after._list);
        ViRefList1 <T> receiveList = after._list;
        ViRefNode1 <T> iter        = list._root._next;

        while (iter != list._root)
        {
            iter._list = receiveList;
            iter       = iter._next;
        }
        ViDebuger.AssertError(receiveList != list);
        ViRefNode1 <T> first = list._root._next;
        ViRefNode1 <T> back  = list._root._pre;
        ViRefNode1 <T> pre   = after._pre;

        _Link(pre, first);
        _Link(back, after);
        receiveList._cnt += list.Size;
        list._Init();
    }
Example #2
0
 public void PushBack(ViRefNode1 <T> node)
 {
     node.Detach();
     ++_cnt;
     node._list = this;
     _PushBefore(_root, node);
 }
Example #3
0
 public void PushBefore(ViRefNode1 <T> after, ViRefNode1 <T> node)
 {
     node.Detach();
     ++_cnt;
     node._list = this;
     _PushBefore(after, node);
 }
Example #4
0
 public void PushAfter(ViRefNode1 <T> before, ViRefNode1 <T> node)
 {
     node.Detach();
     ++_cnt;
     node._list = this;
     _PushAfter(before, node);
 }
Example #5
0
 public void PushFront(ViRefNode1 <T> node)
 {
     node.Detach();
     ++_cnt;
     node._list = this;
     _PushAfter(_root, node);
 }
Example #6
0
    static void _PushBefore(ViRefNode1 <T> after, ViRefNode1 <T> node)
    {
        ViRefNode1 <T> pre = after._pre;

        ViDebuger.AssertError(pre);
        _Link(pre, node);
        _Link(node, after);
    }
Example #7
0
    //+--------------------------------------------------------------------------------------------------------------
    static void _PushAfter(ViRefNode1 <T> before, ViRefNode1 <T> node)
    {
        ViRefNode1 <T> next = before._next;

        ViDebuger.AssertError(next);
        _Link(before, node);
        _Link(node, next);
    }
Example #8
0
 internal void _Detach(ViRefNode1 <T> node)
 {
     ViDebuger.AssertError(node._list == this);
     if (node == _next)        //! 如果是正在迭代的点, 则自动将Next移到下个点
     {
         Next(ref _next);
     }
     _Link(node._pre, node._next);
     node._pre  = null;
     node._next = null;
     --_cnt;
 }
Example #9
0
    public void Clear()
    {
        ViRefNode1 <T> next = _root._next;

        while (next != _root)
        {
            ViRefNode1 <T> nextCopy = next._next;
            next._pre  = null;
            next._next = null;
            next._list = null;
            next       = nextCopy;
        }
        _Init();
    }
Example #10
0
#pragma warning disable 0219
    public static void Test()
    {
        ViRefList1 <int> list  = new ViRefList1 <int>();
        ViRefNode1 <int> node0 = new ViRefNode1 <int>();
        ViRefNode1 <int> node1 = new ViRefNode1 <int>();
        ViRefNode1 <int> node2 = new ViRefNode1 <int>();

        list.PushBack(node0);
        list.PushBack(node1);
        list.PushBack(node2);

        list.BeginIterator();
        while (!list.IsEnd())
        {
            ViRefNode1 <int> node = list.CurrentNode;
            list.Next();
            ///<使用>
            ///</使用>
        }
        list.Clear();
    }
Example #11
0
 public bool IsEnd(ViRefNode1 <T> node)
 {
     return(node == _root);
 }
Example #12
0
 public static void Next(ref ViRefNode1 <T> node)
 {
     ViDebuger.AssertError(node != null && node._next != null);
     node = node._next;
 }
Example #13
0
 static void _Link(ViRefNode1 <T> pre, ViRefNode1 <T> next)
 {
     pre._next = next;
     next._pre = pre;
 }