FindFaster

1.1.1

Quickly find matches in a Swift collection
finnvoor/FindFaster

What's New

v1.1.1

2023-09-07T14:38:57Z
  • Set min swift version to 5.7

FindFaster

Fast asynchronous swift collection search using the Boyer–Moore string-search algorithm. fastSearch can be used with any BidirectionalCollection where Element is Hashable, and is especially useful for searching large amounts of data or long strings and displaying the results as they come in.

FindFaster is used for find and replace in HextEdit, a fast and native macOS hex editor.

Usage

Async

import FindFaster

let text = "Lorem ipsum dolor sit amet"
let search = "or"

for await index in text.fastSearchStream(for: search) {
    print("Found match at: \(index)")
}

// Prints:
//  Found match at: 1
//  Found match at: 15

Sync

import FindFaster

let text = "Lorem ipsum dolor sit amet"
let search = "or"

let results = text.fastSearch(for: search)
print("Results: \(results)")

// Prints:
//  Results: [1, 15]

Closure-based

import FindFaster

let text = "Lorem ipsum dolor sit amet"
let search = "or"

text.fastSearch(for: search) { index in
    print("Found match at: \(index)")
}

// Prints:
//  Found match at: 1
//  Found match at: 15

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Nov 05 2024 06:02:31 GMT-1000 (Hawaii-Aleutian Standard Time)