Skip to content

Releases: nvzqz/RandomKit

v4.4.0

30 Mar 08:01
v4.4.0
Compare
Choose a tag to compare

New Features

  • Added initializers to ReseedingRandomGenerator that take 1 or 0 arguments
    • If Reseeder conforms to SeedableFromOtherRandomGenerator, the reseeder is created from Reseeder.seeded (see a7d1b9b)
    • For Swift >= 3.1, if Reseeder is DeviceRandom or ARC4Random, the reseeder is just Reseeder.default (see da57645)
  • Added floating-point value generation methods for open, half open, and closed intervals (see 59182e5)
  • Added thread-local random generators (see fde214b) 🎉

Improvements

  • Made Double and Float random(using:) about 27 times faster (see 8799af7)
  • Made CGFloat.random(using:) faster , in turn making (NS|UI)Color.random(using:) faster (see a1b60d1)

Fixes

  • Made randomClosed methods be truly on the [0, 1] interval (see 9b0d56b)

v4.3.1

21 Mar 19:01
v4.3.1
Compare
Choose a tag to compare

Changes

  • Random Dates are internally relative to timeIntervalSinceReferenceDate
  • Deprecated Date random(within:using:) for TimeInterval ranges (see 2d30755)

v4.3.0

21 Mar 18:44
v4.3.0
Compare
Choose a tag to compare

New Features

  • Added SeedableFromOtherRandomGenerator protocol
    • Allows for creating a RandomGenerator seeded from another RandomGenerator
  • Added ReseedingRandomGenerator struct for reseeding a base RandomGenerator with another after a certain number of bytes have been generated

Improvements

  • Much faster Array random(using:) for Swift versions before 3.1

Fixes

  • Fix compilation issues by not using API unavailable in Swift 3.1

v4.2.0

15 Mar 19:54
v4.2.0
Compare
Choose a tag to compare

Improvements

  • Made Array init(randomCount:using:) about 4 times faster for integer types by having it safely call init(unsafeRandomCount:using:) (see 350ce9d)

  • Made Dictionary shuffling faster (see 1977f86)

Changes

  • Made Array init(unsafeRandomCount:using:) available for all element types, regardless if they conform to UnsafeRandom (see 71d4bc6)

v4.1.0

15 Mar 11:45
v4.1.0
Compare
Choose a tag to compare

New Features

  • Added seeded static variable to Xoroshiro, Xorshift, XorshiftStar, and MersenneTwister

Improvements

  • Made the init(randomCount:using:) family of Array initializers significantly faster

v4.0.0

07 Mar 04:17
v4.0.0
Compare
Choose a tag to compare

New Features

  • Added randoms(using:) methods to Random- types that return a sequence of random values according to the protocol's specialization
  • Added Bool.random(withWeight:using:) for probability
  • Added more random number generators:
    • Xorshift
    • XorshiftStar
  • NSMutableArray now conforms to Shuffleable and UniqueShuffleable
  • Added randomTuple(using:) global functions for creating tuples of up to six random elements
  • Added ShuffleableInRange and UniqueShuffleableInRange protocols

Improvements

  • Much better init(randomCount:using:) performance for Array and Dictionary
  • Array shuffling is ten times faster
  • Much better performance for random(within:using:) for signed integers

Changes

  • Changed RandomGenerator from an enum to a protocol type
    • As a result, there is no default generator, meaning a generator must be specified as a parameter
  • Random generation functions take a generic RandomGenerator type as an inout argument
  • Removed URL conformance to Random

v3.0.0

10 Dec 02:33
v3.0.0
Compare
Choose a tag to compare

New Features

  • Mersenne Twister random generator
  • All integer types conform to UnsafeRandom
  • Array(unsafeRandomCount:using:) for types conforming to UnsafeRandom
    • For much better performance with integer types, this should be used
  • Added a benchmark target that can be built with the Swift package manager
  • Created RandomWithMaxWidth and RandomWithExactWidth protocols
  • Added randomize(buffer:maxWidth:) and randomize(buffer:exactWidth:) methods to RandomGenerator

Improvements

  • Generating RandomEnum values is significantly faster

Fixes

  • UnicodeScalar now produces a uniform distribution when the Range or ClosedRange spans below 0xD7FF and above 0xE000

Changes

  • Removed RandomDistribution (#29)
  • The devRandom and devURandom cases for RandomGenerator are now a single device case with a DeviceSource parameter
  • The arc4random case for RandomGenerator is now camel-cased arc4Random
  • Float80 extension now available for i386 and x86_64 architectures, not only for macOS
  • URL.random(fromValues:) now returns an Optional<URL>
  • Added ShiftOperations dependency
  • Uses Strideable instead of _Strideable

v2.3.0

21 Nov 10:55
v2.3.0
Compare
Choose a tag to compare

New Features

  • Date now conforms to RandomWithinRange
  • Made unicode scalar based string generation faster
  • Created UnsafeRandom, RandomEnum, RandomWithAll, and RandomRawRepresentable protocols

Fixes

  • Fix which random generator is used for random String. Previously used the default instead of the one passed into the function.

v2.2.1

08 Nov 21:51
v2.2.1
Compare
Choose a tag to compare

Fixes

  • Conformance to Random was removed accidentally for types conforming to FloatingPoint. This has been fixed.

v2.2.0

07 Nov 23:30
v2.2.0
Compare
Choose a tag to compare

Fixes

  • Random Int generation would rely on the size of UIntMax which was apparently not reliable (#28)

Changes

  • If on Linux, Android, or Windows, the arc4random_buf function will be dynamically loaded, making the RandomGenerator.arc4random option more widely available
  • Removed default parameter for randomGenerator for the random(using:) function of Range types
  • Removed Random protocol dependency from Random- protocols