Skip to content

Commit

Permalink
change return type
Browse files Browse the repository at this point in the history
  • Loading branch information
pakosaldanaort committed Nov 6, 2018
1 parent 07732e8 commit 17990d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
http://www.drdobbs.com/database/faster-string-searches/184408171
*/
extension String {
func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Int? {
func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Index? {
// Cache the length of the search pattern because we're going to
// use it a few times and it's expensive to calculate.
let patternLength = pattern.count
Expand Down Expand Up @@ -57,7 +57,7 @@ extension String {
if c == lastChar {

// There is a possible match. Do a brute-force search backwards.
if let k = backwards() { return k.encodedOffset }
if let k = backwards() { return k }

if !usingHorspoolImprovement {
// If no match, we can only safely skip one character ahead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
version = "3.0">
<TimelineItems>
<LoggerValueHistoryTimelineItem
documentLocation = "file:///Users/francisco_saldana/Documents/Nearsoft/Open%20source/swift-algorithm-club/Boyer-Moore-Horspool/BoyerMooreHorspool.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=75&amp;EndingColumnNumber=21&amp;EndingLineNumber=2&amp;StartingColumnNumber=21&amp;StartingLineNumber=2&amp;Timestamp=563159867.556089"
documentLocation = "file:///Users/francisco_saldana/Documents/Nearsoft/Open%20source/swift-algorithm-club/Boyer-Moore-Horspool/BoyerMooreHorspool.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=75&amp;EndingColumnNumber=21&amp;EndingLineNumber=2&amp;StartingColumnNumber=21&amp;StartingLineNumber=2&amp;Timestamp=563161016.665907"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "file:///Users/francisco_saldana/Documents/Nearsoft/Open%20source/swift-algorithm-club/Boyer-Moore-Horspool/BoyerMooreHorspool.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=75&amp;EndingColumnNumber=21&amp;EndingLineNumber=2&amp;StartingColumnNumber=21&amp;StartingLineNumber=2&amp;Timestamp=563159867.5563149"
documentLocation = "file:///Users/francisco_saldana/Documents/Nearsoft/Open%20source/swift-algorithm-club/Boyer-Moore-Horspool/BoyerMooreHorspool.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=75&amp;EndingColumnNumber=21&amp;EndingLineNumber=2&amp;StartingColumnNumber=21&amp;StartingLineNumber=2&amp;Timestamp=563161016.666045"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "file:///Users/francisco_saldana/Documents/Nearsoft/Open%20source/swift-algorithm-club/Boyer-Moore-Horspool/BoyerMooreHorspool.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=75&amp;EndingColumnNumber=21&amp;EndingLineNumber=2&amp;StartingColumnNumber=21&amp;StartingLineNumber=2&amp;Timestamp=563159867.556504"
documentLocation = "file:///Users/francisco_saldana/Documents/Nearsoft/Open%20source/swift-algorithm-club/Boyer-Moore-Horspool/BoyerMooreHorspool.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=75&amp;EndingColumnNumber=21&amp;EndingLineNumber=2&amp;StartingColumnNumber=21&amp;StartingLineNumber=2&amp;Timestamp=563161016.666169"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
Expand Down
4 changes: 2 additions & 2 deletions Boyer-Moore-Horspool/BoyerMooreHorspool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.drdobbs.com/database/faster-string-searches/184408171
*/
extension String {
func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Int? {
func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Index? {
// Cache the length of the search pattern because we're going to
// use it a few times and it's expensive to calculate.
let patternLength = pattern.count
Expand Down Expand Up @@ -50,7 +50,7 @@ extension String {
if c == lastChar {

// There is a possible match. Do a brute-force search backwards.
if let k = backwards() { return k.encodedOffset }
if let k = backwards() { return k }

if !usingHorspoolImprovement {
// If no match, we can only safely skip one character ahead.
Expand Down

0 comments on commit 17990d8

Please sign in to comment.