Random data generation in Swift
ReseedingRandomGenerator
that take 1 or 0 arguments
Reseeder
conforms to SeedableFromOtherRandomGenerator
, the reseeder is created from Reseeder.seeded
(see a7d1b9ba06c93c01d02a9eb2fc3cb3d75fa8694a)Reseeder
is DeviceRandom
or ARC4Random
, the reseeder is just Reseeder.default
(see da576454c4e13895d3607384cded36e275274544)Double
and Float
random(using:)
about 27 times faster (see 8799af7d6538f9da1835037e070d7afa66d99e29)CGFloat.random(using:)
faster , in turn making (NS|UI)Color.random(using:)
faster (see a1b60d13e322abaaa6c6520c9c97cc1f96f56e9b)randomClosed
methods be truly on the [0, 1] interval (see 9b0d56bf4be175612b765b7f37b44e8115577789)Date
s are internally relative to timeIntervalSinceReferenceDate
Date
random(within:using:)
for TimeInterval
ranges (see 2d3075567acd0a7b9cbf4ab7bb1c0f87d1ae914e)SeedableFromOtherRandomGenerator
protocol
RandomGenerator
seeded from another RandomGenerator
ReseedingRandomGenerator
struct for reseeding a base RandomGenerator
with another after a certain number of bytes have been generatedrandom(using:)
for Swift versions before 3.1Made 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)
init(unsafeRandomCount:using:)
available for all element types, regardless if they conform to UnsafeRandom
(see 71d4bc6b20b2b9634244ea15f273a87703bf5723)seeded
static variable to Xoroshiro
, Xorshift
, XorshiftStar
, and MersenneTwister
init(randomCount:using:)
family of Array
initializers significantly fasterrandom
and random(using:)
for when bounds are RandomWithinRange
and RandomWithinClosedRange
typesrandom(within:)
for unsigned integersrandoms(using:)
methods to Random-
types that return a sequence of random values according to the protocol's specializationBool.random(withWeight:using:)
for probabilityXorshift
XorshiftStar
NSMutableArray
now conforms to Shuffleable
and UniqueShuffleable
randomTuple(using:)
global functions for creating tuples of up to six random elementsShuffleableInRange
and UniqueShuffleableInRange
protocolsinit(randomCount:using:)
performance for Array
and Dictionary
Array
shuffling is ten times fasterrandom(within:using:)
for signed integersRandomGenerator
from an enum to a protocol type
RandomGenerator
type as an inout
argumentURL
conformance to Random
UnsafeRandom
Array(unsafeRandomCount:using:)
for types conforming to UnsafeRandom
RandomWithMaxWidth
and RandomWithExactWidth
protocolsrandomize(buffer:maxWidth:)
and randomize(buffer:exactWidth:)
methods to RandomGenerator
RandomEnum
values is significantly fasterUnicodeScalar
now produces a uniform distribution when the Range
or ClosedRange
spans below 0xD7FF
and above 0xE000
RandomDistribution
(#29)devRandom
and devURandom
cases for RandomGenerator
are now a single device
case with a DeviceSource
parameterarc4random
case for RandomGenerator
is now camel-cased arc4Random
Float80
extension now available for i386 and x86_64 architectures, not only for macOSURL.random(fromValues:)
now returns an Optional<URL>
Strideable
instead of _Strideable
Date
now conforms to RandomWithinRange
UnsafeRandom
, RandomEnum
, RandomWithAll
, and RandomRawRepresentable
protocolsRandom
was removed accidentally for types conforming to FloatingPoint
. This has been fixed.