#pragma warning disable 0219 public static void Test() { ViDoubleLink2 <int> list = new ViDoubleLink2 <int>(); { ViDoubleLinkNode2 <int> node1 = new ViDoubleLinkNode2 <int>(); node1.Data = 1; ViDoubleLinkNode2 <int> node2 = new ViDoubleLinkNode2 <int>(); node2.Data = 2; list.PushBack(node1); list.PushBack(node2); {//<正向迭代> ViDoubleLinkNode2 <int> iter = list.GetHead(); while (!list.IsEnd(iter)) { int value = iter.Data; ViDoubleLink2 <int> .Next(ref iter); } } {//<反向迭代> ViDoubleLinkNode2 <int> iter = list.GetTail(); while (!list.IsEnd(iter)) { int value = iter.Data; ViDoubleLink2 <int> .Pre(ref iter); } } } }
public void Active(TAvatar avatar, ViAvatarDurationVisualInterface <TAvatar> kEffect) { if (m_kPriorityList.IsEmpty()) { m_kPriorityList.PushBack(kEffect._priorityNode); kEffect.OnActive(avatar); _OnUpdated(avatar, null); } else { ViDoubleLinkNode2 <ViAvatarDurationVisualInterface <TAvatar> > iter = m_kPriorityList.GetHead(); ViAvatarDurationVisualInterface <TAvatar> pkOldTop = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkOldTop); while (!m_kPriorityList.IsEnd(iter)) { ViAvatarDurationVisualInterface <TAvatar> pkEffect = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkEffect); if (kEffect.Weight > pkEffect.Weight) { break; } ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .Next(ref iter); } ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .PushBefore(iter, kEffect._priorityNode); if (kEffect._priorityNode == m_kPriorityList.GetHead()) { pkOldTop.OnDeactive(avatar); kEffect.OnActive(avatar); _OnUpdated(avatar, pkOldTop); } } }
//------------------------------------------------------------------------- public static void PushBefore(ViDoubleLinkNode2 <T> after, ViDoubleLink2 <T> list) { if (after.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushBefore(after, list); }
//------------------------------------------------------------------------- public static void PushAfter(ViDoubleLinkNode2 <T> before, ViDoubleLink2 <T> list) { if (before.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushAfter(before, list); }
public void Deactive(TAvatar avatar) { ViDoubleLinkNode2 <ViAvatarDurationVisualInterface <TAvatar> > iter = m_kEffectList.GetHead(); while (!m_kEffectList.IsEnd(iter)) { ViAvatarDurationVisualInterface <TAvatar> pkEffect = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkEffect); ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .Next(ref iter); _Deactive(avatar, pkEffect); } }
//------------------------------------------------------------------------- static void _PushBefore(ViDoubleLinkNode2 <T> after, ViDoubleLink2 <T> list) { if (list.IsEmpty()) { return; } ViDoubleLinkNode2 <T> first = list._root._next; ViDoubleLinkNode2 <T> back = list._root._pre; ViDoubleLinkNode2 <T> pre = after._pre; _Link(pre, first); _Link(back, after); list._Init(); }
//------------------------------------------------------------------------- static void _PushAfter(ViDoubleLinkNode2 <T> before, ViDoubleLink2 <T> list) { if (list.IsEmpty()) { return; } ViDoubleLinkNode2 <T> first = list._root._next; ViDoubleLinkNode2 <T> back = list._root._pre; ViDoubleLinkNode2 <T> next = before._next; _Link(before, first); _Link(back, next); list._Init(); }
public float Length() { float len = 0.0f; ViVector3 prePos = _currentPos; ViDoubleLinkNode2 <ViRouteNode> iter = _nodes.GetHead(); while (!_nodes.IsEnd(iter)) { ViRouteNode value = iter.Data; ViDoubleLink2 <ViRouteNode> .Next(ref iter); // len += Distance(value._pos, prePos); prePos = value._pos; } return(len); }
public void Clear(TAvatar avatar) { if (m_kPriorityList.IsEmpty()) { return; } ViDoubleLinkNode2 <ViAvatarDurationVisualInterface <TAvatar> > iter = m_kPriorityList.GetHead(); ViAvatarDurationVisualInterface <TAvatar> top = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(top); top.OnDeactive(avatar); while (!m_kPriorityList.IsEnd(iter)) { ViAvatarDurationVisualInterface <TAvatar> pkEffect = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkEffect); ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .Next(ref iter); pkEffect._priorityNode.Detach(); } }
//------------------------------------------------------------------------- public void Reset() { ViDoubleLinkNode2 <ViAstarStep> iter = _openList.GetHead(); while (!_openList.IsEnd(iter)) { iter.Data.Clear(); ViDoubleLink2 <ViAstarStep> .Next(ref iter); } _openList.Clear(); // iter = _closeList.GetHead(); while (!_closeList.IsEnd(iter)) { iter.Data.Clear(); ViDoubleLink2 <ViAstarStep> .Next(ref iter); } _closeList.Clear(); // _openHeap.Clear(); }
//------------------------------------------------------------------------- public void PushFront(ViDoubleLink2 <T> list) { _PushAfter(_root, list); }
//------------------------------------------------------------------------- public void PushBack(ViDoubleLink2 <T> list) { _PushBefore(_root, list); }
public void Delete(ViDoubleLink2 <T> nodes) { _nodes.PushBack(nodes); }