本文整理汇总了C#中PriorityQueue.peek方法的典型用法代码示例。如果您正苦于以下问题:C# PriorityQueue.peek方法的具体用法?C# PriorityQueue.peek怎么用?C# PriorityQueue.peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.peek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: evaluateActions
private void evaluateActions()
{
List<string> debugText = new List<string>();
if (debug)
debugText.Add("****EVALUATE****");
dirty = false;
PriorityQueue endeavourQueue = new PriorityQueue ();
List<Endeavour> staleEndeavours = new List<Endeavour>();
//print("\tCurrent Endeavours");
foreach (Endeavour action in currentEndeavours) {
if (action.isStale ()) {
//print("\t\tstale: " + action.getName());
action.stopExecution ();
staleEndeavours.Add (action);
} else {
//print("\t\t++" + action.getName());
availableEndeavours.Add(action);
}
}
//print("\tAvailable Endeavours");
foreach (Endeavour action in availableEndeavours) {
if (action.isStale()) {
//print("\t\t--" + action.getName());
staleEndeavours.Add(action);
} else {
//print("\t\t++" + action.getName());
endeavourQueue.Enqueue(action);
}
}
foreach (Endeavour action in staleEndeavours) {
availableEndeavours.Remove(action);
currentEndeavours.Remove(action);
}
HashSet<Endeavour> proposedEndeavours = new HashSet<Endeavour> ();
Dictionary<System.Type, int> componentMap = getComponentUsageMap ();
while (endeavourQueue.Count > 0) {
if (((Endeavour)endeavourQueue.peek()).isReady(componentMap)) {
Endeavour action = (Endeavour)endeavourQueue.Dequeue();
if(debug) {
debugText.Add("+" + action.getName().PadRight(12) + "->" + action.getPriority());
}
proposedEndeavours.Add(action);
availableEndeavours.Remove(action);
}
else {
Endeavour action = (Endeavour)endeavourQueue.Dequeue();
if(debug) {
string number = action.getPriority().ToString("0.0##");
debugText.Add("-" + action.getName().PadRight(12) + "->" + number);
}
if(action.active) {
action.stopExecution();
}
}
}
// All previous actions MUST be stopped before we start the new ones
foreach(Endeavour action in proposedEndeavours) {
if(!action.active) {
action.execute();
}
}
currentEndeavours = proposedEndeavours;
if (debug)
lines = debugText;
}