@@ -387,10 +387,10 @@ extension Sequence {
387
387
/// Returns the elements of the sequence, shuffled using the given generator
388
388
/// as a source for randomness.
389
389
///
390
- /// You use this method to randomize the elements of a sequence when you
391
- /// are using a custom random number generator. For example, you can shuffle
392
- /// the numbers between `0` and `9` by calling the `shuffled(using:)` method
393
- /// on that range:
390
+ /// You use this method to randomize the elements of a sequence when you are
391
+ /// using a custom random number generator. For example, you can shuffle the
392
+ /// numbers between `0` and `9` by calling the `shuffled(using:)` method on
393
+ /// that range:
394
394
///
395
395
/// let numbers = 0...9
396
396
/// let shuffledNumbers = numbers.shuffled(using: &myGenerator)
@@ -401,6 +401,11 @@ extension Sequence {
401
401
/// - Returns: An array of this sequence's elements in a shuffled order.
402
402
///
403
403
/// - Complexity: O(*n*), where *n* is the length of the sequence.
404
+ /// - Note: The algorithm used to shuffle a sequence may change in a future
405
+ /// version of Swift. If you're passing a generator that results in the
406
+ /// same shuffled order each time you run your program, that sequence may
407
+ /// change when your program is compiled using a different version of
408
+ /// Swift.
404
409
@inlinable
405
410
public func shuffled< T: RandomNumberGenerator > (
406
411
using generator: inout T
@@ -419,8 +424,8 @@ extension Sequence {
419
424
/// let shuffledNumbers = numbers.shuffled()
420
425
/// // shuffledNumbers == [1, 7, 6, 2, 8, 9, 4, 3, 5, 0]
421
426
///
422
- /// This method is equivalent to calling the version that takes a generator,
423
- /// passing in the system's default random generator.
427
+ /// This method is equivalent to calling `shuffled(using:)`, passing in the
428
+ /// system's default random generator.
424
429
///
425
430
/// - Returns: A shuffled array of this sequence's elements.
426
431
///
@@ -448,6 +453,11 @@ extension MutableCollection where Self : RandomAccessCollection {
448
453
/// the collection.
449
454
///
450
455
/// - Complexity: O(*n*), where *n* is the length of the collection.
456
+ /// - Note: The algorithm used to shuffle a collection may change in a future
457
+ /// version of Swift. If you're passing a generator that results in the
458
+ /// same shuffled order each time you run your program, that sequence may
459
+ /// change when your program is compiled using a different version of
460
+ /// Swift.
451
461
@inlinable
452
462
public mutating func shuffle< T: RandomNumberGenerator > (
453
463
using generator: inout T
@@ -469,15 +479,14 @@ extension MutableCollection where Self : RandomAccessCollection {
469
479
470
480
/// Shuffles the collection in place.
471
481
///
472
- /// Use the `shuffle()` method to randomly reorder the elements of an
473
- /// array.
482
+ /// Use the `shuffle()` method to randomly reorder the elements of an array.
474
483
///
475
484
/// var names = ["Alejandro", "Camila", "Diego", "Luciana", "Luis", "Sofía"]
476
485
/// names.shuffle(using: myGenerator)
477
486
/// // names == ["Luis", "Camila", "Luciana", "Sofía", "Alejandro", "Diego"]
478
487
///
479
- /// This method is equivalent to calling the version that takes a generator,
480
- /// passing in the system's default random generator.
488
+ /// This method is equivalent to calling `shuffle(using:)`, passing in the
489
+ /// system's default random generator.
481
490
///
482
491
/// - Complexity: O(*n*), where *n* is the length of the collection.
483
492
@inlinable
0 commit comments