RangePermute 1.0.1

Memory efficient psuedo-randomly permuted enumerator for C#/.NET to enumerate gigantic ranges.

Install-Package RangePermute -Version 1.0.1
dotnet add package RangePermute --version 1.0.1
<PackageReference Include="RangePermute" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RangePermute --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

RangePermute

Memory efficient psuedo-randomly permuted enumerator for C#/.NET to enumerate gigantic ranges.

Say you want to generate a random permutation of numbers in range [0-2^50), without duplicates. Naive approach to get decent pseudo-random permutations would need prohibitively large amount of memory.
This library can generate such enumerations using constant memory, and is suitable for Linq-style consumption.

With UInt64, currently we can support 2^64. Can easily be modified to support range up-to 2^128. Internals are 128-bit already.

using RangePermute;
...
foreach(var idx in RangeEnumerable.Range(100000000))
{
    // do something with idx
    // idx will be between 0 (inclusive) and 100000000 (exlusive)
    ...
}

Relevant reading:

  • Luby, Michael, and Charles Rackoff. "How to Construct Pseudorandom Permutations from Pseudorandom Functions." SIAM Journal on Computing, vol. 17, no. 2, 1988, pp. 373–386.
  • Black, John, and Phillip Rogaway. "Ciphers with Arbitrary Finite Domains." The Cryptographers Track at the Rsa Conference, 2002. [http://web.cs.ucdavis.edu/~rogaway/papers/subset.pdf]

Credits

Pretty much a C# port of https://pypi.python.org/pypi/shuffled/ .

RangePermute

Memory efficient psuedo-randomly permuted enumerator for C#/.NET to enumerate gigantic ranges.

Say you want to generate a random permutation of numbers in range [0-2^50), without duplicates. Naive approach to get decent pseudo-random permutations would need prohibitively large amount of memory.
This library can generate such enumerations using constant memory, and is suitable for Linq-style consumption.

With UInt64, currently we can support 2^64. Can easily be modified to support range up-to 2^128. Internals are 128-bit already.

using RangePermute;
...
foreach(var idx in RangeEnumerable.Range(100000000))
{
    // do something with idx
    // idx will be between 0 (inclusive) and 100000000 (exlusive)
    ...
}

Relevant reading:

  • Luby, Michael, and Charles Rackoff. "How to Construct Pseudorandom Permutations from Pseudorandom Functions." SIAM Journal on Computing, vol. 17, no. 2, 1988, pp. 373–386.
  • Black, John, and Phillip Rogaway. "Ciphers with Arbitrary Finite Domains." The Cryptographers Track at the Rsa Conference, 2002. [http://web.cs.ucdavis.edu/~rogaway/papers/subset.pdf]

Credits

Pretty much a C# port of https://pypi.python.org/pypi/shuffled/ .

Release Notes

First release.

  • .NETCoreApp 2.1

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 78 3/19/2019
1.0.0 273 2/23/2018