//------------------------------------------------------------------------- static void _PushBefore(EbDoubleLinkNode2 <T> after, EbDoubleLinkNode2 <T> node) { EbDoubleLinkNode2 <T> pre = after._pre; _Link(pre, node); _Link(node, after); }
//--------------------------------------------------------------------- public void Delete(EbDoubleLinkNode2 <T> node) { if (node != null) { mListNode.PushBack(node); } }
//------------------------------------------------------------------------- public static void Test() { EbDoubleLinkList2 <int> list = new EbDoubleLinkList2 <int>(); EbDoubleLinkNode2 <int> node1 = new EbDoubleLinkNode2 <int>(); node1.Data = 1; EbDoubleLinkNode2 <int> node2 = new EbDoubleLinkNode2 <int>(); node2.Data = 2; list.PushBack(node1); list.PushBack(node2); {// 正向迭代 EbDoubleLinkNode2 <int> iter = list.GetHead(); while (!list.IsEnd(iter)) { int value = iter.Data; EbDoubleLinkList2 <int> .Next(ref iter); } } {// 反向迭代 EbDoubleLinkNode2 <int> iter = list.GetTail(); while (!list.IsEnd(iter)) { int value = iter.Data; EbDoubleLinkList2 <int> .Pre(ref iter); } } }
//------------------------------------------------------------------------- static void _PushAfter(EbDoubleLinkNode2 <T> before, EbDoubleLinkNode2 <T> node) { EbDoubleLinkNode2 <T> next = before._next; _Link(before, node); _Link(node, next); }
//--------------------------------------------------------------------- public void Append(EbVector3 pos) { EbDoubleLinkNode2 <EbRouteNode> node = mNodeAlloc.New(); node.Data._eventId = EbRouteNode.NULL_EVENT; node.Data._pos = pos; mListNode.PushBack(node); }
//--------------------------------------------------------------------- public void Append(EbVector3 pos, uint event_id) { EbDoubleLinkNode2 <EbRouteNode> node = mNodeAlloc.New(); node.Data._eventId = event_id; node.Data._pos = pos; mListNode.PushBack(node); }
//------------------------------------------------------------------------- public void SetValue(T value) { EbDoubleLinkNode2 <T> next = _root._next; while (next != _root) { next.Data = value; next = next._next; } }
//------------------------------------------------------------------------- public void Detach() { if (_pre != null) { _pre._next = _next; _next._pre = _pre; _pre = null; _next = null; } }
//------------------------------------------------------------------------- public static void PushAfter(EbDoubleLinkNode2 <T> before, EbDoubleLinkList2 <T> list) { if (before.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushAfter(before, list); }
//------------------------------------------------------------------------- public static void PushBefore(EbDoubleLinkNode2 <T> after, EbDoubleLinkList2 <T> list) { if (after.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushBefore(after, list); }
//--------------------------------------------------------------------- public EbDoubleLinkNode2 <T> New() { if (mListNode.IsEmpty()) { return(new EbDoubleLinkNode2 <T>(new T())); } else { EbDoubleLinkNode2 <T> node = mListNode.GetHead(); node.Detach(); return(node); } }
//------------------------------------------------------------------------- public void Clear() { EbDoubleLinkNode2 <T> next = _root._next; while (next != _root) { EbDoubleLinkNode2 <T> nextCopy = next._next; next._pre = null; next._next = null; next = nextCopy; } _Init(); }
//------------------------------------------------------------------------- public void ClearAndClearContent() { EbDoubleLinkNode2 <T> next = _root._next; while (next != _root) { EbDoubleLinkNode2 <T> nextCopy = next._next; next._pre = null; next._next = null; next.Data = default(T); next = nextCopy; } _Init(); }
//------------------------------------------------------------------------- static void _PushAfter(EbDoubleLinkNode2 <T> before, EbDoubleLinkList2 <T> list) { if (list.IsEmpty()) { return; } EbDoubleLinkNode2 <T> first = list._root._next; EbDoubleLinkNode2 <T> back = list._root._pre; EbDoubleLinkNode2 <T> next = before._next; _Link(before, first); _Link(back, next); list._Init(); }
//------------------------------------------------------------------------- static void _PushBefore(EbDoubleLinkNode2 <T> after, EbDoubleLinkList2 <T> list) { if (list.IsEmpty()) { return; } EbDoubleLinkNode2 <T> first = list._root._next; EbDoubleLinkNode2 <T> back = list._root._pre; EbDoubleLinkNode2 <T> pre = after._pre; _Link(pre, first); _Link(back, after); list._Init(); }
//--------------------------------------------------------------------- public float Length() { float len = 0.0f; EbVector3 pos_pre = mCurrentPos; EbDoubleLinkNode2 <EbRouteNode> iter = mListNode.GetHead(); while (!mListNode.IsEnd(iter)) { EbRouteNode value = iter.Data; EbDoubleLinkList2 <EbRouteNode> .Next(ref iter); len += Distance(value._pos, pos_pre); pos_pre = value._pos; } return(len); }
//--------------------------------------------------------------------- public void Reset() { EbDoubleLinkNode2 <EbAstarStep> iter = mOpenList.GetHead(); while (!mOpenList.IsEnd(iter)) { iter.Data.Clear(); EbDoubleLinkList2 <EbAstarStep> .Next(ref iter); } mOpenList.Clear(); iter = mCloseList.GetHead(); while (!mCloseList.IsEnd(iter)) { iter.Data.Clear(); EbDoubleLinkList2 <EbAstarStep> .Next(ref iter); } mCloseList.Clear(); mOpenHeap.Clear(); }
//------------------------------------------------------------------------- public void PushBack(EbDoubleLinkNode2 <T> node) { node.Detach(); _PushBefore(_root, node); }
//------------------------------------------------------------------------- public static void PushBefore(EbDoubleLinkNode2 <T> after, EbDoubleLinkNode2 <T> node) { node.Detach(); _PushBefore(after, node); }
//------------------------------------------------------------------------- public static void PushAfter(EbDoubleLinkNode2 <T> before, EbDoubleLinkNode2 <T> node) { node.Detach(); _PushAfter(before, node); }
//------------------------------------------------------------------------- public static void Pre(ref EbDoubleLinkNode2 <T> node) { node = node._pre; }
//------------------------------------------------------------------------- public static void Next(ref EbDoubleLinkNode2 <T> node) { node = node._next; }
//------------------------------------------------------------------------- public void PushFront(EbDoubleLinkNode2 <T> node) { node.Detach(); _PushAfter(_root, node); }
//------------------------------------------------------------------------- static void _Link(EbDoubleLinkNode2 <T> pre, EbDoubleLinkNode2 <T> next) { pre._next = next; next._pre = pre; }
//------------------------------------------------------------------------- public bool IsEnd(EbDoubleLinkNode2 <T> node) { return(node == _root); }