旋转。在C#中的列表最简单的方法 [英] Easiest way to Rotate a List in c#
本文介绍了旋转。在C#中的列表最简单的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
列表说,我有一个List 列表与LT; INT> {1,2,3,4,5}
Lists say I have a list List<int> {1,2,3,4,5}
旋转方式:
=> {2,3,4,5,1} => {3,4,5,1,2} => {4,5,1,2,3}
也许是旋转没有为此最好的词,但希望你明白我的手段
Maybe rotate is not the best word for this, but hope you understand what I means
我的问题,什么最简单的方法(简称code,C#4 LINQ的准备),并且不会被表现被击中(合理的绩效)
My question, whats the easiest way (in short code, c# 4 Linq ready), and will not be hit by performance (reasonable performance)
感谢。
推荐答案
您可以实现它作为一个队列。出列和排队的值相同。
You could implement it as a queue. Dequeue and Enqueue the same value.
**,我不知道有关性能在列表转换成一个队列,但人们upvoted我的意见,所以我张贴这作为一个答案。
**I wasn't sure about performance in converting a List to a Queue, but people upvoted my comment, so I'm posting this as an answer.
这篇关于旋转。在C#中的列表最简单的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文