本文整理汇总了C#中Model.List.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# List.Reverse方法的具体用法?C# List.Reverse怎么用?C# List.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.Reverse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sort
/// <summary>
/// Sorts the specified list.
/// </summary>
/// <param name="list">The list.</param>
/// <param name="sortExpression">The sort expression.</param>
/// <param name="sortDirection">The sort direction.</param>
public static List<Resume> Sort(List<Resume> list, string sortExpression,
string sortDirection)
{
if (!string.IsNullOrEmpty(sortExpression))
{
list.Sort(new ListSorter<Resume>(sortExpression));
}
if (sortDirection != null && sortDirection == "Desc")
{
list.Reverse();
}
return list;
}
示例2: Star
public ICollection<Helper.Point> Star( Helper.Point posIni, Helper.Point posFinal, out int totalCost)
{
var heapBorder = new Heap<Elem>();
// Console.WriteLine("cheguei no astar");
List<Elem> explored = new List<Elem>();
/* Array to verify if a position was explored */
var hasExpl = new bool[qtdNodes,qtdNodes];
var inBorder = new bool[qtdNodes,qtdNodes];
hasExpl.Initialize();
inBorder.Initialize();
Elem father = new Elem(0, posIni);
heapBorder.HeapAdd( h(posIni,posFinal), father );
while (heapBorder.HeapSize() > 0 )
{
father = heapBorder.HeapExtractMin().Item3 ;
inBorder[father.pos.x, father.pos.y] = false;
if( father.pos.Equals(posFinal) )
break;
explored.Insert(0, father);
hasExpl[father.pos.x, father.pos.y] = true;
foreach (var child in father.pos.Neighborhood( posFinal) )
{
int accChild = 0;
accChild = father.accCost + 1;
if (hasExpl[child.x, child.y] && accChild >= father.accCost)
continue;
if (inBorder[child.x, child.y] == false || accChild < father.accCost)
{
heapBorder.HeapAdd(h(child, posFinal) + accChild, new Elem(accChild, child, father.pos));
inBorder[child.x, child.y] = true;
}
}
}
var pathReturn = new List<Helper.Point>();
pathReturn.Insert(0, father.pos );
totalCost = father.accCost;
if (!father.parent.HasValue)
return pathReturn;
var currParent = father.parent.Value ;
for (int i = 0 , j = 1; i < explored.Count; i++)
{
if (explored[i].pos.Equals(currParent) )
{
pathReturn.Insert(j,explored[i].pos);
j++;
currParent = explored[i].parent.HasValue ? explored[i].parent.Value : posIni ;
//Debug.WriteLine("custo "+explored[i].accCost);
}
}
pathReturn.Reverse();
return pathReturn.Skip(1).ToList();
}
示例3: MoveDown
/// <summary>
/// Move items down in the queue
/// </summary>
private void MoveDown()
{
// If there are selected items and the last item is not selected
if (list_queue.SelectedIndices.Count > 0 &&
!list_queue.SelectedIndices.Contains(list_queue.Items[list_queue.Items.Count - 1].Index))
{
// Copy the selected indices to preserve them during the movement
List<int> selectedIndices = new List<int>(list_queue.SelectedIndices.Count);
foreach (int selectedIndex in list_queue.SelectedIndices)
selectedIndices.Add(selectedIndex);
// Reverse the indices to move the items down from last to first (preserves indices)
selectedIndices.Reverse();
// Move down each selected item
foreach (int selectedIndex in selectedIndices)
queue.QueueManager.MoveDown(selectedIndex);
// Keep the selected item(s) selected, now moved down one index
foreach (int selectedIndex in selectedIndices)
if (selectedIndex + 1 < list_queue.Items.Count) // Defensive programming: ensure index is good
list_queue.Items[selectedIndex + 1].Selected = true;
}
list_queue.Select(); // Activate the control to show the selected items
}
示例4: GetPathForNode
// Получения маршрута.
private static List<Point> GetPathForNode(PathNode pathNode)
{
var result = new List<Point>();
var currentNode = pathNode;
while (currentNode != null)
{
result.Add(currentNode.Position);
currentNode = currentNode.CameFrom;
}
result.Reverse();
return result;
}