#diff #algorithm #lcs #slice #difference #compute #wu

wu-diff

Compute differences between two slices using wu(the O(NP)) algorithm

3 releases

Uses old Rust 2015

0.1.2 Oct 15, 2019
0.1.1 Oct 6, 2018
0.1.0 Jun 25, 2018

#553 in Algorithms

Download history 518/week @ 2023-11-29 566/week @ 2023-12-06 530/week @ 2023-12-13 337/week @ 2023-12-20 662/week @ 2023-12-27 813/week @ 2024-01-03 505/week @ 2024-01-10 334/week @ 2024-01-17 471/week @ 2024-01-24 621/week @ 2024-01-31 543/week @ 2024-02-07 643/week @ 2024-02-14 383/week @ 2024-02-21 492/week @ 2024-02-28 677/week @ 2024-03-06 463/week @ 2024-03-13

2,134 downloads per month
Used in 8 crates (6 directly)

MIT license

34KB
611 lines

wu-diff-rs

Compute differences between two slices using wu(the O(NP)) algorithm.

CircleCI Build status

Example

extern crate wu_diff;

use self::wu_diff::*;

fn main() {
    let old = vec!["foo", "bar", "baz"];
    let new = vec!["foo", "baz", "hoge"];

    for diff in wu_diff::diff(&old, &new) {
        match diff {
            DiffResult::Added(a) => {
                let i = a.new_index.unwrap();
                println!("+{} new index = {}", new[i], i)
            }
            DiffResult::Common(c) => {
                let new_index = c.new_index.unwrap();
                let old_index = c.old_index.unwrap();
                println!(
                    " {} old index = {}, new index = {}",
                    new[new_index], old_index, new_index
                )
            }
            DiffResult::Removed(r) => {
                let i = r.old_index.unwrap();
                println!("-{} old index = {}", old[i], i)
            }
        }
    }
}

You can also run example as shown below.

rustup run nightly cargo run --example example

LICENSE

The MIT License (MIT)

Copyright (c) 2018 @bokuweb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Dependencies

~0–1.4MB
~31K SLoC