本文整理汇总了C#中System.Collections.Queue.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# Queue.OrderBy方法的具体用法?C# Queue.OrderBy怎么用?C# Queue.OrderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Queue
的用法示例。
在下文中一共展示了Queue.OrderBy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FCFS_Test
public void FCFS_Test()
{
Queue<Request> queue = new Queue<Request>(array);
Queue<Request> resultQueue = new Queue<Request>(array);
queue = RequestAlgorithms.FCFS(queue, new Drive.Stats(100, 50, i => 10 + i * 0.2, 0.3, 0.5, null, 0, 0, true, 10, 0.2));
Assert.IsTrue(resultQueue.OrderBy(request => request.ArrivalTime).Zip(queue, (request, request1) => comparisonFunc(request, request1)).Aggregate((b, b1) => b && b1));
}
示例2: SSTF
public static Queue<Request> SSTF(Queue<Request> requestQueue, Drive.Stats driveStatistics)
{
if (requestQueue.Count <= 1)
return new Queue<Request>(requestQueue);
return
new Queue<Request>(
requestQueue.OrderBy(request => Utilities.RequestDistance(request, driveStatistics)));
}
示例3: RandamSortByCount
/// <summary>
/// 回数順にランダムソートを行う
/// </summary>
/// <param name="Team"></param>
public void RandamSortByCount(ref Queue<Member> Team)
{
IEnumerable<Member> query = Team.OrderBy(member => member.day.Count).ThenBy(member => member.Score);
foreach (Member member in query)
{
Team.Dequeue();
Team.Enqueue(member);
}
}
示例4: AStar
public void AStar(Grafo grafo, Nodo origem, Nodo destino)
{
grafo.nodos = this.limpaNodos(grafo.nodos);
fila = new Queue<Nodo>();
Visitacao = new List<Nodo>();
foreach (Nodo nodo in grafo.nodos) {
if (nodo == origem)
continue;
nodo.TempoInicio = int.MaxValue;
nodo.predecessor = null;
nodo.Cor = Cor.Branco;
}
origem.Cor = Cor.Cinza;
origem.TempoInicio = 0;
origem.predecessor = null;
// Adiciona o nodo de origem na fila.
fila.Enqueue(origem);
while (fila.Count > 0) {
Nodo u = fila.Dequeue();
Visitacao.Add(u);
if (u == destino)
break;
foreach (Nodo v in u.ListaAdj) {
if (v.Cor == Cor.Branco) {
v.Cor = Cor.Cinza;
v.TempoInicio = u.TempoInicio + 1;
v.predecessor = u;
//fila.enqueueNodeOrdered(v, 'F');
fila.Enqueue(v);
fila = new Queue<Nodo>(fila.OrderBy(linq => linq.F));
}
}
u.Cor = Cor.Preto;
}
this.fazCaminhoSolucao();
}
示例5: FCFS
public static Queue<Request> FCFS(Queue<Request> requestQueue, Drive.Stats driveStatistics)
{
if (requestQueue.Count <= 1)
return new Queue<Request>(requestQueue);
return new Queue<Request>(requestQueue.OrderBy(request => request.ArrivalTime));
}
示例6: RandamSortByNo
/// <summary>
/// 番号順にランダムソートを行う
/// </summary>
/// <param name="Team"></param>
public void RandamSortByNo(ref Queue<Member> Team)
{
IEnumerable<Member> query = Team.OrderBy(member => member.No);
foreach (Member member in query)
{
Team.Dequeue();
Team.Enqueue(member);
}
}