Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

iaingalloway/ShuffleBag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShuffleBag

A simple shuffled collection implementation in C# using the Fisher-Yates algorithm.

How to get it?

PM> Install-Package ShuffleBag

How to use it?

Just add using ShuffleBag and you can easily shuffle collections:-

var suits = Enum.GetValues(typeof(Suit)).Cast<Suit>();
var ranks = Enum.GetValues(typeof(Rank)).Cast<Rank>();

var cards = suits.SelectMany(
    suit => ranks,
    (suit, rank) => new Card(suit, rank)); // Cards not included!

var deck = cards.Shuffle(); // Easily shuffle collections
var hand = deck.Take(5);

var reshufflingDeck = cards.ShuffleIndefinitely() // "Reshuffle" when empty
var reallyBigHand = deck.Take(104);

About

A simple shuffled collection implementation in C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages