-
-
Notifications
You must be signed in to change notification settings - Fork 4
feat!: Introduce new PriorityOrderedSet
#57
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
Conversation
Benchmark ResultsPackage ordered_set:
Benchmarks provided with 💙 by Dart Benchmark Action. |
b3979be
to
157ed46
Compare
PriorityOrderedSet
Pull Request Test Coverage Report for Build 14359965723Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
I'm not too fond of comparing
as a name, maybe MappedOrderedSet
or something instead?
I also don't like the names, but MappedOrderedSet is essentially the other one (takes a mapping function)! the og one takes a comparator function instead |
Ah right, of course, maybe the other one should be called |
Yeah I agree with Mapping for the other one. One of the helper functions is already called that. We migh need to rework those names, which is fine. |
But I am open to other names, maybe |
I like that, go for it! Oooor could we have |
|
I'm happy with |
Alright, sounds good! I guess we should update some docs in the readme too. |
@spydon I spent some time thinking about and after much deliberation I reached these conclusions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! 😍
This introduces a new type of ordered set that takes a mapper function instead of a comparing function, and thus is able to perform some optimizations much needed in Flame.
In order not to break backwards compatibility too much, the following approach is taken:
OrderedSet
becomes an "interface" (in Dart world that is an abstract class)ComparingOrderedSet
is the old one, new one isPriorityOrderedSet
OrderedSet
interface to create any sets with helper functionsQueryableOrderedSet
takes in the underlyingOrderedSet
so it works with both versionsThe new
PriorityOrderedSet
uses a splay tree map instead of splay tree set and thus caches the priorities on the map keys. That means you can safely update priorities or have dynamic priority functions and have consistent behaviour before rebalancing.This is a much nicer underlying fix for flame-engine/flame#3363 than how we did it on the Flame side.