Add tests and make minor fixes to PriorityQueue.
This commit is contained in:
@@ -76,17 +76,19 @@ namespace OpenRA.Primitives
|
||||
return At(lastLevel, lastIndex);
|
||||
}
|
||||
|
||||
public T Peek() { return At(0, 0); }
|
||||
public T Peek()
|
||||
{
|
||||
if (level <= 0 && index <= 0)
|
||||
throw new InvalidOperationException("PriorityQueue empty.");
|
||||
return At(0, 0);
|
||||
}
|
||||
|
||||
public T Pop()
|
||||
{
|
||||
if (level == 0 && index == 0)
|
||||
throw new InvalidOperationException("Attempting to pop empty PriorityQueue");
|
||||
|
||||
var ret = At(0, 0);
|
||||
var ret = Peek();
|
||||
BubbleInto(0, 0, Last());
|
||||
if (--index < 0)
|
||||
index = (1 << --level) - 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user