Example #1
0
#pragma warning disable 0219
    public static void Test()
    {
        ViDoubleLink1 <int> list = new ViDoubleLink1 <int>();
        {
            ViDoubleLinkNode1 <int> node1 = new ViDoubleLinkNode1 <int>();
            ViDoubleLinkNode1 <int> node2 = new ViDoubleLinkNode1 <int>();
            list.PushBack(node1);
            list.PushBack(node2);

            {            ///<正向迭代>
                ViDoubleLinkNode1 <int> iter = list.GetHead();
                while (!list.IsEnd(iter))
                {
                    ViDoubleLink1 <int> .Next(ref iter);

                    ///<使用>
                    ///</使用>
                }
            }
            {            ///<反向迭代>
                ViDoubleLinkNode1 <int> iter = list.GetTail();
                while (!list.IsEnd(iter))
                {
                    ViDoubleLink1 <int> .Pre(ref iter);

                    ///<使用>
                    ///</使用>
                }
            }
        }
    }
Example #2
0
    static void _PushBefore(ViDoubleLinkNode1 <T> after, ViDoubleLinkNode1 <T> node)
    {
        ViDoubleLinkNode1 <T> pre = after._pre;

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

        ViDebuger.AssertError(next);
        _Link(before, node);
        _Link(node, next);
    }
Example #4
0
 public static void PushBefore(ViDoubleLinkNode1 <T> after, ViDoubleLink1 <T> list)
 {
     if (after.IsAttach() == false)
     {
         return;
     }
     if (list.IsEmpty())
     {
         return;
     }
     _PushBefore(after, list);
 }
Example #5
0
 public static void PushAfter(ViDoubleLinkNode1 <T> before, ViDoubleLink1 <T> list)
 {
     if (before.IsAttach() == false)
     {
         return;
     }
     if (list.IsEmpty())
     {
         return;
     }
     _PushAfter(before, list);
 }
Example #6
0
    public void Clear()
    {
        ViDoubleLinkNode1 <T> next = _root._next;

        while (next != _root)
        {
            ViDoubleLinkNode1 <T> nextCopy = next._next;
            next._pre  = null;
            next._next = null;
            next       = nextCopy;
        }
        _Init();
    }
Example #7
0
    static void _PushBefore(ViDoubleLinkNode1 <T> after, ViDoubleLink1 <T> list)
    {
        if (list.IsEmpty())
        {
            return;
        }
        ViDoubleLinkNode1 <T> first = list._root._next;
        ViDoubleLinkNode1 <T> back  = list._root._pre;
        ViDoubleLinkNode1 <T> pre   = after._pre;

        _Link(pre, first);
        _Link(back, after);
        list._Init();
    }
Example #8
0
    static void _PushAfter(ViDoubleLinkNode1 <T> before, ViDoubleLink1 <T> list)
    {
        if (list.IsEmpty())
        {
            return;
        }
        ViDoubleLinkNode1 <T> first = list._root._next;
        ViDoubleLinkNode1 <T> back  = list._root._pre;
        ViDoubleLinkNode1 <T> next  = before._next;

        _Link(before, first);
        _Link(back, next);
        list._Init();
    }
Example #9
0
    //
    private static void _AddEvent(ViDoubleLink1 <ViTimeNodeInterface> list, ViTimeNodeInterface node)
    {
        ViDoubleLinkNode1 <ViTimeNodeInterface> iter = list.GetHead();

        while (!list.IsEnd(iter))
        {
            ViTimeNodeInterface timeNode = iter as ViTimeNodeInterface;
            ViDebuger.AssertError(timeNode);
            ViDoubleLink1 <ViTimeNodeInterface> .Next(ref iter);

            if (timeNode.Time > node.Time)
            {
                ViDoubleLink1 <ViTimeNodeInterface> .PushBefore(iter, node);

                return;
            }
        }
        list.PushBack(node);
    }
Example #10
0
    private static void _AddEvent(ViDoubleLink1 <ViTimeNodeInterface> list, TimeRoll timeRoll)
    {
        ViDoubleLinkNode1 <ViTimeNodeInterface> iter = list.GetHead();

        while (!list.IsEnd(iter))
        {
            ViTimeNodeInterface timeNode = iter as ViTimeNodeInterface;
            ViDebuger.AssertError(timeNode);
            ViDoubleLink1 <ViTimeNodeInterface> .Next(ref iter);

            if (timeRoll.InRange(timeNode.Time))
            {
                timeRoll.Add(timeNode);
            }
            else
            {
                break;
            }
        }
    }
Example #11
0
 public bool IsEnd(ViDoubleLinkNode1 <T> node)
 {
     return(node == _root);
 }
Example #12
0
 public static void PushBefore(ViDoubleLinkNode1 <T> after, ViDoubleLinkNode1 <T> node)
 {
     node.Detach();
     _PushBefore(after, node);
 }
Example #13
0
 public static void PushAfter(ViDoubleLinkNode1 <T> before, ViDoubleLinkNode1 <T> node)
 {
     node.Detach();
     _PushAfter(before, node);
 }
Example #14
0
 public static void Pre(ref ViDoubleLinkNode1 <T> node)
 {
     ViDebuger.AssertError(node != null && node._pre != null);
     node = node._pre;
 }
Example #15
0
 public void PushFront(ViDoubleLinkNode1 <T> node)
 {
     node.Detach();
     _PushAfter(_root, node);
 }
Example #16
0
 static void _Link(ViDoubleLinkNode1 <T> pre, ViDoubleLinkNode1 <T> next)
 {
     pre._next = next;
     next._pre = pre;
 }
Example #17
0
 //+-----------------------------------------------------------------------------------------------------------------------------
 public static void Next(ref ViDoubleLinkNode1 <T> node)
 {
     ViDebuger.AssertError(node != null && node._next != null);
     node = node._next;
 }
Example #18
0
 //+-----------------------------------------------------------------------------------------------------------------------------
 public void PushBack(ViDoubleLinkNode1 <T> node)
 {
     node.Detach();
     _PushBefore(_root, node);
 }