Created
November 18, 2021 10:36
-
-
Save RubenNL/0083c4bea7978a2d49b9087b3b0f5340 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace GUI | |
{ | |
public class Bag | |
{ | |
private readonly Random _random; | |
private Queue<Matrix> _bag = new(); //using queue for easy pop/dequeue. | |
public Bag(int seed) | |
{ | |
_random = new Random(seed); | |
} | |
private void Fill() | |
{ | |
_bag = new Queue<Matrix>(Matrix.GetMatrixes().OrderBy(_ => _random.Next())); | |
} | |
public Matrix GetNextMatrix() | |
{ | |
if (_bag.Count == 0) Fill(); | |
return _bag.Dequeue(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment