Comments (6)
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.
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.
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.
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.
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.
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)
- Improve time complexity of getIndex
- Byzantine LSEQ-Node.add problem HOT 3
- LSEQ + Tombstones HOT 3
- Inefficient LSEQNode.getIndex
- A few "scary" questions... HOT 4
- Why the random strategy choice? HOT 2
- Does this library use Tombstones? HOT 3
- Error: Cannot find module 'lodash.merge'
- Optimize json output by adding toJSON()
- add toText() method
- Space improvement of node HOT 1
- Factorize lseq.get(i) && lseq.get(i+1) in insert
- Specification of functions applyInsert and applyRemove HOT 1
- Delay conversion fromNodetoId
- Run code within browsers
- Performance comparison between lseqarray and lseqtree
- Fast access to the last index used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lseqtree.