Skip to content

Commit af6b86d

Browse files
committed
Merge remote-tracking branch 'origin/lazyIter' into lazyIter
2 parents d3bc38e + cc33816 commit af6b86d

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Sources/Regex/AGMatchLazyList.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public struct AGMatchLazyList: Equatable, Sequence {
1414

1515
public let baseString: String
1616
private let regex: NSRegularExpression
17-
18-
init(withBase base: String, regex: NSRegularExpression) {
17+
18+
init(base: String, regex: NSRegularExpression) {
1919
self.baseString = base
2020
self.regex = regex
2121
}
2222

2323
public __consuming func makeIterator() -> AGMatchLazyList.Iterator {
24-
return AGMatchLazyListIterator(withBase: baseString,
24+
return AGMatchLazyListIterator(base: baseString,
2525
regex: self.regex)
2626
}
2727
}

Sources/Regex/AGMatchLazyListIterator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public struct AGMatchLazyListIterator: IteratorProtocol {
4343
return result
4444
}
4545

46-
init(withBase base: String, regex: NSRegularExpression) {
46+
init(base: String, regex: NSRegularExpression) {
4747
self.baseString = base
4848
self.regex = regex
4949
}

Sources/Regex/AGRegex.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@_exported import Foundation
1010

1111
public class AGRegex {
12-
12+
1313
private var regex: NSRegularExpression
1414

1515
public init(_ regex: NSRegularExpression) {
@@ -19,9 +19,9 @@ public class AGRegex {
1919

2020
extension AGRegex {
2121

22-
public func matchAll(_ str: String,
23-
options: NSRegularExpression.MatchingOptions = [])
24-
-> AGMatchList {
22+
public func makeMatchList(_ str: String,
23+
options: NSRegularExpression.MatchingOptions = [])
24+
-> AGMatchList {
2525
let matched = regex.matches(
2626
in: str,
2727
options: options,
@@ -59,9 +59,9 @@ extension AGRegex {
5959
return result
6060
}
6161

62-
public func matchAllLazliy (_ str: String,
62+
public func makeMatchStream(_ str: String,
6363
option: NSRegularExpression.MatchingOptions = [])
64-
-> AGMatchLazyList {
65-
return AGMatchLazyList(withBase: str, regex: self.regex)
64+
-> AGMatchLazyList {
65+
return AGMatchLazyList(base: str, regex: self.regex)
6666
}
6767
}

Tests/AGRegexTest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AGRegexTest: XCTestCase {
1616
let r = try! NSRegularExpression(pattern: "ai", options: [])
1717
let regex = AGRegex(r)
1818
let str = "The rain in Spain"
19-
let actual = regex.matchAll(str)
19+
let actual = regex.makeMatchList(str)
2020
let expect = AGMatchList(base: str, matching: [
2121
AGMatch(start: 5, end: 7, base: str, groups: ["ai"]),
2222
AGMatch(start: 14, end: 16, base: str, groups: ["ai"]),
@@ -29,7 +29,7 @@ class AGRegexTest: XCTestCase {
2929
let r = try! NSRegularExpression(pattern: "ai", options: [])
3030
let regex = AGRegex(r)
3131
let str = "The rain in Spain"
32-
let actual = regex.matchAll(str).first
32+
let actual = regex.makeMatchList(str).first
3333
let expect = AGMatch(start: 5, end: 7, base: str, groups: ["ai"])
3434
XCTAssertEqual(actual, expect)
3535
}
@@ -38,7 +38,7 @@ class AGRegexTest: XCTestCase {
3838
let r = try! NSRegularExpression(pattern: "ai", options: [])
3939
let regex = AGRegex(r)
4040
let str = "The rain in Spain"
41-
let actual = regex.matchAll(str).last
41+
let actual = regex.makeMatchList(str).last
4242
let expect = AGMatch(start: 14, end: 16, base: str, groups: ["ai"])
4343
XCTAssertEqual(actual, expect)
4444
}
@@ -76,7 +76,7 @@ class AGRegexTest: XCTestCase {
7676

7777
var actuals: [String] = []
7878

79-
for m in regex.matchAllLazliy(str) {
79+
for m in regex.makeMatchStream(str) {
8080
let actual = "\(m.group(2)) * \(m.group(1))"
8181
actuals.append(actual)
8282
}

0 commit comments

Comments
 (0)