diff --git a/src/DotRecast.Core/RcSortedQueue.cs b/src/DotRecast.Core/RcSortedQueue.cs index 03c9960..e8918c1 100644 --- a/src/DotRecast.Core/RcSortedQueue.cs +++ b/src/DotRecast.Core/RcSortedQueue.cs @@ -45,20 +45,24 @@ namespace DotRecast.Core _items.Clear(); } - public T Top() + private void Balance() { if (_dirty) { _items.Sort(_comparison); // reverse _dirty = false; } + } + public T Peek() + { + Balance(); return _items[_items.Count - 1]; } public T Dequeue() { - var node = Top(); + var node = Peek(); _items.Remove(node); return node; } @@ -82,5 +86,13 @@ namespace DotRecast.Core { return 0 == _items.Count; } + + public List ToList() + { + Balance(); + var temp = new List(_items); + temp.Reverse(); + return temp; + } } } \ No newline at end of file diff --git a/src/DotRecast.Detour/DtNodeQueue.cs b/src/DotRecast.Detour/DtNodeQueue.cs index 8fb399b..5e8368f 100644 --- a/src/DotRecast.Detour/DtNodeQueue.cs +++ b/src/DotRecast.Detour/DtNodeQueue.cs @@ -36,14 +36,14 @@ namespace DotRecast.Detour m_heap.Clear(); } - public DtNode Top() + public DtNode Peek() { - return m_heap.Top(); + return m_heap.Peek(); } public DtNode Pop() { - var node = Top(); + var node = Peek(); m_heap.Remove(node); return node; }