We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent5f8f384 commitbf24ad0Copy full SHA for bf24ad0
Shuffle/README.markdown
@@ -12,7 +12,7 @@ extension Array {
12
var temp= [Element]()
13
while!isEmpty {
14
let i=random(count)
15
-let obj=removeAtIndex(i)
+let obj=remove(at:i)
16
temp.append(obj)
17
}
18
self= temp
@@ -44,7 +44,7 @@ Here is a much improved version of the shuffle algorithm:
44
```swift
45
extensionArray {
46
publicmutatingfuncshuffle() {
47
-for iin(count-1).stride(through:1,by:-1) {
+for iinstride(from:count-1,through:1,by:-1) {
48
let j=random(i+1)
49
if i!= j {
50
swap(&self[i],&self[j])
@@ -96,8 +96,8 @@ There is a slight variation on this algorithm that is useful for when you want t
96
Here is the code:
97
98
99
-publicfuncshuffledArray(n:Int)-> [Int] {
100
-var a= [Int](count: n,repeatedValue:0)
+publicfuncshuffledArray(_n:Int)-> [Int] {
+var a= [Int](repeating:0,count: n)
101
for iin0..<n {
102
103