-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error for next > prev can occur in valid sequence #3
Comments
|
This is correct—thank you! I'll accept a PR. |
Note that the same issue exists at https://github.com/usecanvas/logoot_ex/blob/51d0f950f2f5d7c0de9c82b65a416f8a4865d1ea/lib/logoot/sequence.ex#L211 |
Just a comment that you can speed up insertion if a binary search is used (i think this is also suggested in the paper):
|
If we have a sequence p and q where the first identifier of p is less than that of q, but with no gap between them, then the second identifier of p is greater than the second identifier of q, the Error on line 218 will be triggered.
For example
p = [[0, 3], [100, 3]]
q = [[1, 2], [99, 2]]
This is valid since p < q, and both positions look to me like they could be produced while running.
Say we are inserting as site 2 - in this case we see that [0, 3] < [1,2], but cannot insert an ident between them because we have site id 2 giving [0, 2] < [0, 3] (and couldn't insert as [1, 2] either since it is equal to q's first ident). So we move on to the next digit, and the error triggers.
In fact we can use any position of the form [[0, 3], [x, 2]] for x > 100 and <= MAX - we just need the ident to be greater than p's second ident - it's not necessary any more to be < the ident from q, since we already incorporate an earlier ident < the one than q.
I think this can be done very simply by just modifying the first recursion on line 212:
nextPos.slide(1) needs to be just the empty list instead, thus removing the restriction on the upper limit of subsequent idents. This means that the Error doesn't trigger any more, since we are comparing the maximum identifier to the one from p, rather than the actual identifier from q, and also means that we will produce a valid position between p and q. The error will still trigger if p is actually > q, when we get to an index where p's ident > q's ident BEFORE an index where p's ident < q's ident. Behaviour when p and q have equal idents is unaltered.
The text was updated successfully, but these errors were encountered: