All Projects → Frugghi → Swiftlcs

Frugghi / Swiftlcs

Licence: mit
Swift implementation of the longest common subsequence (LCS) algorithm.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftlcs

Diffabledatasources
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
Stars: ✭ 601 (+190.34%)
Mutual labels:  algorithm, diff
Differencekit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Stars: ✭ 2,986 (+1342.51%)
Mutual labels:  algorithm, diff
Editscript
A library designed to diff and patch Clojure data structures
Stars: ✭ 281 (+35.75%)
Mutual labels:  algorithm, diff
Nanomorph
🚅 - Hyper fast diffing algorithm for real DOM nodes
Stars: ✭ 621 (+200%)
Mutual labels:  algorithm, diff
Onp
The implementations of "An O(NP) Sequence Comparison Algorithm"
Stars: ✭ 100 (-51.69%)
Mutual labels:  algorithm, diff
Textdistance
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
Stars: ✭ 2,575 (+1143.96%)
Mutual labels:  algorithm, diff
Dwifft
Swift Diff
Stars: ✭ 1,822 (+780.19%)
Mutual labels:  algorithm, diff
Dtl
diff template library written by C++
Stars: ✭ 180 (-13.04%)
Mutual labels:  algorithm, diff
Htmlsimilarity
网页相似度判断:根据网页结构判断页面相似性 ,可用于相似度计算、越权检测等(Determine page similarity based on HTML page structure)
Stars: ✭ 189 (-8.7%)
Mutual labels:  diff
Rrt Algorithms
n-dimensional RRT, RRT* (RRT-Star)
Stars: ✭ 195 (-5.8%)
Mutual labels:  algorithm
Fuse
🔍 Fuzzy search for PHP based on the Bitap algorithm
Stars: ✭ 189 (-8.7%)
Mutual labels:  algorithm
Beginners Python Examples
Basic Python CLI programs
Stars: ✭ 190 (-8.21%)
Mutual labels:  algorithm
Arts
每周一道算法一本书
Stars: ✭ 199 (-3.86%)
Mutual labels:  algorithm
Algorithms
This repository is for learning and understanding how algorithms work.
Stars: ✭ 189 (-8.7%)
Mutual labels:  algorithm
Difference.rs
Rust text diffing and assertion library
Stars: ✭ 206 (-0.48%)
Mutual labels:  diff
Rank bm25
A Collection of BM25 Algorithms in Python
Stars: ✭ 187 (-9.66%)
Mutual labels:  algorithm
Split Diff
Side-by-side file compare for the Atom text editor.
Stars: ✭ 188 (-9.18%)
Mutual labels:  diff
Algorithms Notes
《算法(第4版)》笔记及代码 | 《Algorithms(Fourth Edition)》notes & code
Stars: ✭ 206 (-0.48%)
Mutual labels:  algorithm
Java String Similarity
Implementation of various string similarity and distance algorithms: Levenshtein, Jaro-winkler, n-Gram, Q-Gram, Jaccard index, Longest Common Subsequence edit distance, cosine similarity ...
Stars: ✭ 2,403 (+1060.87%)
Mutual labels:  algorithm
Textrank
🌀 ⚡️ 🌍 TextRank (automatic text summarization) for PHP8
Stars: ✭ 193 (-6.76%)
Mutual labels:  algorithm

SwiftLCS

Build Status Carthage compatible Pods Pod platforms

SwitLCS provides an extension of Collection that finds the indexes of the longest common subsequence with another collection.

The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences). It differs from problems of finding common substrings: unlike substrings, subsequences are not required to occupy consecutive positions within the original sequences.

The project is based on the Objective-C implementation of NSArray+LongestCommonSubsequence.

📦 Installation

CocoaPods

CocoaPods is the dependency manager for Swift and Objective-C Cocoa projects. It has over ten thousand libraries and can help you scale your projects elegantly.

Add this to your Podfile:

use_frameworks!

pod 'SwiftLCS'

Carthage

Carthage builds your dependencies and provides you with binary frameworks, but you retain full control over your project structure and setup.

Add this to your Cartfile:

github "Frugghi/SwiftLCS"

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Add SwiftLCS to your Package.swift dependencies:

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/Frugghi/SwiftLCS.git", majorVersion: 1, minor: 3)
    ]
)

Manual

Include SwiftLCS.swift into your project.

📖 Documentation

The API documentation is available here.

💻 Usage

Import the framework:

import SwiftLCS

String

let x = "abracadabra"
let y = "yabbadabbadoo"

let z = x.longestCommonSubsequence(y) // abadaba

Array

let x = [1, 2, 3, 4, 5, 6, 7]
let y = [8, 9, 2, 10, 4, 11, 6, 12]

let z = x.longestCommonSubsequence(y) // [2, 4, 6]

Indexes

let x = [1, 2, 3, 4, 5, 6, 7]
let y = [8, 9, 2, 10, 4, 11, 6, 12]

let diff = x.diff(y)
// diff.commonIndexes: [1, 3, 5]
// diff.addedIndexes: [0, 1, 3, 5, 7]
// diff.removedIndexes: [0, 2, 4, 6]

⚠️ Objective-C

Object comparison of Objective-C objects is done through the isEquals: method, so be sure that the implementations is correct otherwise SwiftLCS will not return the correct indexes.

📄 License LICENSE

SwiftLCS is released under the MIT license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].