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(); }
public void PushBack(ViRefNode1 <T> node) { node.Detach(); ++_cnt; node._list = this; _PushBefore(_root, node); }
public void PushBefore(ViRefNode1 <T> after, ViRefNode1 <T> node) { node.Detach(); ++_cnt; node._list = this; _PushBefore(after, node); }
public void PushAfter(ViRefNode1 <T> before, ViRefNode1 <T> node) { node.Detach(); ++_cnt; node._list = this; _PushAfter(before, node); }
public void PushFront(ViRefNode1 <T> node) { node.Detach(); ++_cnt; node._list = this; _PushAfter(_root, node); }
static void _PushBefore(ViRefNode1 <T> after, ViRefNode1 <T> node) { ViRefNode1 <T> pre = after._pre; ViDebuger.AssertError(pre); _Link(pre, node); _Link(node, after); }
//+-------------------------------------------------------------------------------------------------------------- static void _PushAfter(ViRefNode1 <T> before, ViRefNode1 <T> node) { ViRefNode1 <T> next = before._next; ViDebuger.AssertError(next); _Link(before, node); _Link(node, next); }
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; }
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(); }
#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(); }
public bool IsEnd(ViRefNode1 <T> node) { return(node == _root); }
public static void Next(ref ViRefNode1 <T> node) { ViDebuger.AssertError(node != null && node._next != null); node = node._next; }
static void _Link(ViRefNode1 <T> pre, ViRefNode1 <T> next) { pre._next = next; next._pre = pre; }