GithubHelp home page GithubHelp logo

Mutable subCounters about lseqtree HOT 6 CLOSED

chat-wane avatar chat-wane commented on September 2, 2024
Mutable subCounters

from lseqtree.

Comments (6)

Chat-Wane avatar Chat-Wane commented on September 2, 2024

Thank you for the bug report! I will fix that asap ( hopefully at the end of the week).

I'll gladly answer your questions. You can ask them at <>

from lseqtree.

Tavistock avatar Tavistock commented on September 2, 2024

here's what i did, modified getIndexes function to return a collection like yours but if it hits a no index instead of returning -1 it returns nil (in your case -1) append to the collection. so it would return something like [1 2 0 5 nil]. from here if it is something like [1 2 3 4] it already has a node there so you go to that node and check if it has a element and if it does no-op if it doesn't increase all the sub-counters leading to it then add it. if it is an array ending in a nil you know it is not there so you can crawl to it using the indexes, increasing sub-counters on the way, and add the node into the last indices children.

The only reason I mention this is because i found that a simple modification of getIndexes function increases it's usefulness and wanted to share.

Edit: you use the return -1 if not found semantic so you would have to change it from:
if (indexes === -1)
to
if (indexes[indexes.length -1 ] === -1)

from lseqtree.

Chat-Wane avatar Chat-Wane commented on September 2, 2024

Ah, indeed.

I was considering a solution where the recursive function returns a boolean on whether or not it actually inserts the new element in the lower branches of the tree. You solution is way much easier to write and to understand, thanks.

Btw, your project looks nice. I was thinking about referencing it in the readme, is that ok with you?

from lseqtree.

Tavistock avatar Tavistock commented on September 2, 2024

yea, that would be great. I may write some blog posts about crdt's and focus on sequence ones, if I mention you would your github handle be good or would you prefer something else.

from lseqtree.

Chat-Wane avatar Chat-Wane commented on September 2, 2024

Ok, great, I'll do. You can reference whatever seems the most appropriate to you ;) I would be happy to read the post, if you happen to write it.

from lseqtree.

Chat-Wane avatar Chat-Wane commented on September 2, 2024

I finally fix the issue. Nevertheless, I didn't implemented the way you suggested. I tried, but it actually increased the algorithm complexity... Instead, I just checked if the node was actually added before incrementing the counter (using the returning value of the add function).

from lseqtree.

Related Issues (18)

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.