#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); ///<使用> ///</使用> } } } }
static void _PushBefore(ViDoubleLinkNode1 <T> after, ViDoubleLinkNode1 <T> node) { ViDoubleLinkNode1 <T> pre = after._pre; ViDebuger.AssertError(pre); _Link(pre, node); _Link(node, after); }
//+----------------------------------------------------------------------------------------------------------------------------- static void _PushAfter(ViDoubleLinkNode1 <T> before, ViDoubleLinkNode1 <T> node) { ViDoubleLinkNode1 <T> next = before._next; ViDebuger.AssertError(next); _Link(before, node); _Link(node, next); }
public static void PushBefore(ViDoubleLinkNode1 <T> after, ViDoubleLink1 <T> list) { if (after.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushBefore(after, list); }
public static void PushAfter(ViDoubleLinkNode1 <T> before, ViDoubleLink1 <T> list) { if (before.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushAfter(before, list); }
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(); }
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(); }
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(); }
// 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); }
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; } } }
public bool IsEnd(ViDoubleLinkNode1 <T> node) { return(node == _root); }
public static void PushBefore(ViDoubleLinkNode1 <T> after, ViDoubleLinkNode1 <T> node) { node.Detach(); _PushBefore(after, node); }
public static void PushAfter(ViDoubleLinkNode1 <T> before, ViDoubleLinkNode1 <T> node) { node.Detach(); _PushAfter(before, node); }
public static void Pre(ref ViDoubleLinkNode1 <T> node) { ViDebuger.AssertError(node != null && node._pre != null); node = node._pre; }
public void PushFront(ViDoubleLinkNode1 <T> node) { node.Detach(); _PushAfter(_root, node); }
static void _Link(ViDoubleLinkNode1 <T> pre, ViDoubleLinkNode1 <T> next) { pre._next = next; next._pre = pre; }
//+----------------------------------------------------------------------------------------------------------------------------- public static void Next(ref ViDoubleLinkNode1 <T> node) { ViDebuger.AssertError(node != null && node._next != null); node = node._next; }
//+----------------------------------------------------------------------------------------------------------------------------- public void PushBack(ViDoubleLinkNode1 <T> node) { node.Detach(); _PushBefore(_root, node); }