Add implementation of shuffle on IdentifiedArray (#254)

* add shuffle

* Update Tests/ComposableArchitectureTests/IdentifiedArrayTests.swift

* Update IdentifiedArrayTests.swift

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
This commit is contained in:
Jefferson Setiawan
2020-08-14 06:52:14 +07:00
committed by GitHub
parent 86843a4dcc
commit fffefb9c22
3 changed files with 56 additions and 0 deletions

View File

@@ -190,6 +190,15 @@ where ID: Hashable {
try areInIncreasingOrder(self.dictionary[$0]!, self.dictionary[$1]!)
}
}
public mutating func shuffle<T>(using generator: inout T) where T : RandomNumberGenerator {
ids.shuffle(using: &generator)
}
public mutating func shuffle() {
var rng = SystemRandomNumberGenerator()
self.shuffle(using: &rng)
}
}
extension IdentifiedArray: CustomDebugStringConvertible {