[英]How do I use Queues to randomize images?
I previously asked a question about randomizing images in Windows Form application (Visual Studio) for an Uno game.我之前问过一个关于在 Windows 窗体应用程序 (Visual Studio) 中为 Uno 游戏随机化图像的问题。 I was suggested an approach using queues.
有人建议我使用队列的方法。 I'm afraid that I can't get it to work, mostly because I can't figure out how to queue the files and then dequeue them when the files are applied to the image boxes.
恐怕我无法让它工作,主要是因为我不知道如何对文件进行排队,然后在将文件应用于图像框时将它们出列。 How can I do this?
我怎样才能做到这一点?
Forgot using queues for randomizing.忘记使用队列进行随机化。 What you need to do is:
你需要做的是:
Here is an example of how to do that这是一个如何做到这一点的例子
private static Random rng = new Random();
public static void Shuffle<T>(this IList<T> list)
{
int n = list.Count;
while (n > 1) {
n--;
int k = rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
var queue = new Queue(list);
var queue = new Queue(list);
Enqueue
and Dequeue
commands to draw.Enqueue
和Dequeue
命令进行绘制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.