RoundRobin 2.0.1

A simple implementation of round robin in c# with circular linked list

Install-Package RoundRobin -Version 2.0.1
dotnet add package RoundRobin --version 2.0.1
<PackageReference Include="RoundRobin" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RoundRobin --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RoundRobin, 2.0.1"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

Round Robin implementation in C#

Alt Text

Round Robin is a very simple but in the same time very useful algorithm,
but there is no native implementation in C#. So here is a simple but powerful and thread-safe implementation of the Round Robin algorithm in C#.

<!-- > Source Code -->

Nuget

Usage

//installation
dotnet add package RoundRobin
Install-Package RoundRobin
var roundRobinList = new RoundRobinList<int>(
    new List<int>{
        1,2,3,4,5
    }
);

for (var i = 0; i < 8; i++)
{
    Write($"{roundRobinList.Next()},");
}

//result
//1,2,3,4,5,1,2,3,

Also you can increase/decrease the weights, by doing so you will be able to increase/decrease the priority of an element in the Round Robin list

var roundRobinList = new RoundRobinList<int>(
    new List<int>{
        1,2,3,4,5
    }
);

//the weight of the element 1 will be increase by 2 units
roundRobinList.IncreaseWeight(element:1, amount:2);

for (var i = 0; i < 10; i++)
{
    Write($"{roundRobinList.Next()},");
}

//result
//1,1,1,2,3,4,5,1,1,1

Enjoy coding 😃

Round Robin implementation in C#

Alt Text

Round Robin is a very simple but in the same time very useful algorithm,
but there is no native implementation in C#. So here is a simple but powerful and thread-safe implementation of the Round Robin algorithm in C#.

<!-- > Source Code -->

Nuget

Usage

//installation
dotnet add package RoundRobin
Install-Package RoundRobin
var roundRobinList = new RoundRobinList<int>(
    new List<int>{
        1,2,3,4,5
    }
);

for (var i = 0; i < 8; i++)
{
    Write($"{roundRobinList.Next()},");
}

//result
//1,2,3,4,5,1,2,3,

Also you can increase/decrease the weights, by doing so you will be able to increase/decrease the priority of an element in the Round Robin list

var roundRobinList = new RoundRobinList<int>(
    new List<int>{
        1,2,3,4,5
    }
);

//the weight of the element 1 will be increase by 2 units
roundRobinList.IncreaseWeight(element:1, amount:2);

for (var i = 0; i < 10; i++)
{
    Write($"{roundRobinList.Next()},");
}

//result
//1,1,1,2,3,4,5,1,1,1

Enjoy coding 😃

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.0.1 201 1/27/2021
2.0.0 13,805 1/13/2020
1.0.0 221 1/12/2020