Skip to content
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

Insertion to a BindingSeq should not take O(log n) time #23

Open
Atry opened this issue Oct 10, 2016 · 5 comments
Open

Insertion to a BindingSeq should not take O(log n) time #23

Atry opened this issue Oct 10, 2016 · 5 comments

Comments

@Atry
Copy link
Collaborator

Atry commented Oct 10, 2016

Current implementation use Vector, which consumes linear time when an element is inserted or removed in the middle of a BindingSeq.
While, finger tree could be O(1) or O(log n).

@Atry Atry changed the title Replace the underlying data structure of BindingSeq to scalazCord Replace the underlying data structure of BindingSeq to scalaz.Cord Oct 11, 2016
@Atry Atry changed the title Replace the underlying data structure of BindingSeq to scalaz.Cord Replace the underlying data structure of BindingSeq to finger tree Oct 11, 2016
@deontologic
Copy link

Aren't Vectors effectively constant for inserts/deletion? Perhaps I don't understand your use case.

@Atry
Copy link
Collaborator Author

Atry commented Oct 20, 2016

I meant Vector.patch method, which are called whenever a @BindingSeq changes

cache = cache.patch(event.from, mappedNewChildren, event.replaced)

Vector.patch is O(n) in current version (2.10.6 or 2.11.8) of Scala.

@deontologic
Copy link

Ah, I see.

I'd be careful using a finger tree, though. Despite having a great theoretical performance, actual implementations are pretty unsatisfactory (at least on the JVM). If you're considering using them over the default red-black trees, I'd recommend benchmarking.

I hope to read the source this weekend, so perhaps then I can be of more assistance

@Atry Atry changed the title Replace the underlying data structure of BindingSeq to finger tree Insert to a BindingSeq should not take O(log n) time Oct 20, 2016
@Atry
Copy link
Collaborator Author

Atry commented Oct 20, 2016

@kantianethics I agree. I changed the title of this issue in order to fit solutions other than finger tree.

@Atry Atry changed the title Insert to a BindingSeq should not take O(log n) time Insertion to a BindingSeq should not take O(log n) time Oct 20, 2016
@Atry
Copy link
Collaborator Author

Atry commented Oct 20, 2016

I created an issue at https://issues.scala-lang.org/browse/SI-10001

Atry added a commit to Atry/Binding.scala that referenced this issue Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants