Skip to content

Commit

Permalink
Add Array.init(repeating:count:)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcprux committed Nov 2, 2023
1 parent 3dec73d commit 9794490
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches: '*'
tags: "[0-9]+.[0-9]+.[0-9]+"
schedule:
- cron: '0 11,21 * * *'
- cron: '0 0,4,8,12,16,20 * * *'
workflow_dispatch:
pull_request:

Expand Down
3 changes: 3 additions & 0 deletions Sources/SkipLib/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public struct Array<Element>: RandomAccessCollection, RangeReplaceableCollection
public init() {
}

public init(repeating: Element, count: Int) {
}

public init(_ sequence: any Sequence<Element>) {
}
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/SkipLib/Skip/Array.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class Array<Element>: RandomAccessCollection<Element>, RangeReplaceableCollectio
_mutableList = ArrayList()
}

@Suppress("UNCHECKED_CAST")
constructor(repeating: Element, count: Int) {
_collection = List(count) { repeating }
}

@Suppress("UNCHECKED_CAST")
constructor(collection: Sequence<Element>, nocopy: Boolean = false, shared: Boolean = false) {
if (nocopy) {
Expand Down

0 comments on commit 9794490

Please sign in to comment.