Code Monkey home page Code Monkey logo

swiftlcs's People

Contributors

frugghi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swiftlcs's Issues

wrong commonIndexes

let first = [0,1,1,2,3]
let second = [0,1,2,3] 
let diff = first.diff(second)

print("commonIndexes: \(diff.commonIndexes)")

result in
commonIndexes: [0, 1, 2, 3, 4]

expect: [0, 1, 3, 4] or [0, 2, 3, 4]

Maybe caused by wrong endIndex in prefix func

func prefix(_ otherCollection: Self, count: Int, suffix: Int, by areEquivalent: (Element, Element) -> Bool) -> (Int, [Index]) {
        ...
        let endIndex = self.index(self.startIndex, offsetBy: count - suffix)
       let endIndex = self.index(self.startIndex, offsetBy: count - suffix - 1) // maybe???
       ...
    }

Crash when the length is a bit long

Whenever the length of the text is a bit long (about 510 characters) the algorithm crashes in the following function:

and this line: else if table[i][j] == table[i][j-1]

/// Walks back through the generated table to generate the diff.
fileprivate static func diffFromIndices(_ table: [[Int]], _ x: [Element], _ y: [Element], _ i: Int, _ j: Int) -> Diff {

    if i == 0 && j == 0 {
        return Diff<Element>(results: [])
    } else if i == 0 {
        return diffFromIndices(table, x, y, i, j-1) + DiffStep.insert(j-1, y[j-1])
    } else if j == 0 {
        return diffFromIndices(table, x, y, i - 1, j) + DiffStep.delete(i-1, x[i-1])
    } else if table[i][j] == table[i][j-1] {
        return diffFromIndices(table, x, y, i, j-1) + DiffStep.insert(j-1, y[j-1])
    } else if table[i][j] == table[i-1][j] {
        return diffFromIndices(table, x, y, i - 1, j) + DiffStep.delete(i-1, x[i-1])
    } else {
        return diffFromIndices(table, x, y, i-1, j-1)
    }

}

Does Not Recognize Common Indexes For PFObject

For some reason SwiftLCS does not recognize the two collections as containing common indexes. The two arrays being compared are exactly the same, but SwiftLCS removes all indexes and adds them back instead of simply recognizing that they are common indexes.

I essentially have a query that pulls all data, and I have SwiftLCS compare the cached data array to the new, in-coming data array.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.