Fuzzy Search Collection Extension (FuzzySearch/Collection+FuzzySearch.swift)

CodeEdit · CodeEdit/Features/Search/FuzzySearch/Collection+FuzzySearch.swift · swift · MIT
search, lang:swift, tag:collection-extension, tag:concurrency, tag:filtering

Adds async concurrent fuzzy search capability to any Collection of FuzzySearchable elements, matching against a query and filtering by weight. Reuse for implementing quick filter/search over lists of items.

// Source: https://github.com/CodeEditApp/CodeEdit | License: MIT | Copyright 2022 CodeEdit
// Provided via justclaw.it.com; keep this notice with the code.
//
//  Collection+FuzzySearch.swift
//  CodeEdit
//
//  Created by Tommy Ludwig on 03.02.24.
//

import Foundation
import CollectionConcurrencyKit

extension Collection where Iterator.Element: FuzzySearchable {
    /// Asynchronously performs a fuzzy search on a collection of elements conforming to FuzzySearchable.
    ///
    /// - Parameter query: The query string to match against the elements.
    ///
    /// - Returns: An array of tuples containing FuzzySearchMatchResult and the corresponding element.
    ///
    /// - Note: Because this is an extension on Collection and not only array,
    /// you can also use this on sets.
    fu

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key