RandomKit Versions Save

Random data generation in Swift

v4.4.0

7 years ago

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 a7d1b9ba06c93c01d02a9eb2fc3cb3d75fa8694a)
    • For Swift >= 3.1, if Reseeder is DeviceRandom or ARC4Random, the reseeder is just Reseeder.default (see da576454c4e13895d3607384cded36e275274544)
  • Added floating-point value generation methods for open, half open, and closed intervals (see 59182e5b25f3a3bed1cf88682af7727651d0a906)
  • Added thread-local random generators (see fde214b1c24b9d9d5bc6835aca4744a4331de195) :tada:

Improvements

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

Fixes

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

v4.3.1

7 years ago

Changes

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

v4.3.0

7 years ago

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

7 years ago

Improvements

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

  • Made Dictionary shuffling faster (see 1977f86ee139c38b87613fb459179e3372cb63cf)

Changes

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

v4.1.0

7 years ago

New Features

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

Improvements

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

v2.1.0

7 years ago

Improvements

  • Range types now have random and random(using:) for when bounds are RandomWithinRange and RandomWithinClosedRange types
  • Improved performance for retrieving random elements from collections

Fixes

  • Fixed random(within:) for unsigned integers

v4.0.0

7 years ago

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

7 years ago

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

7 years ago

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

7 years ago

Fixes

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