-
Notifications
You must be signed in to change notification settings - Fork 323
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
Map Implementation #1222
Map Implementation #1222
Conversation
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.
There's some stuff I'd like to discuss. Let me know when you're around to talk.
get : Any -> Any ! No_Value_For_Key | ||
get key = |
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.
Do we not want a more general Maybe a
here, rather than the specific error? It seems more composable to me to use a common primitive.
Bin s k v l r -> | ||
Bin s k (function v) (l.map function) (r.map function) | ||
Tip -> Tip | ||
|
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.
I'd like to see a fold
(left) as well.
Helper for inserting a new key-value pair into a map. | ||
The algorithm used here is based on the paper "Implementing Sets Efficiently |
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.
Helper for inserting a new key-value pair into a map. | |
The algorithm used here is based on the paper "Implementing Sets Efficiently | |
Helper for inserting a new key-value pair into a map. | |
The algorithm used here is based on the paper "Implementing Sets Efficiently |
Controls the difference between inner and outer siblings of a heavy subtree. | ||
Used to decide between a double and a single rotation. | ||
ratio : Integer | ||
ratio = 2 | ||
|
||
## PRIVATE | ||
|
||
Controls the maximum size difference between subtrees. | ||
delta : Integer | ||
delta = 3 |
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.
I would specify why these values are chosen (e.g. from the paper, from Data.Map.Strict
).
@@ -0,0 +1,79 @@ | |||
from Base import all |
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.
Not a fan of where this file is. I think we should unify the collections under Base.Collection
(including List
and Vector
). Can we talk about stdlib structure?
String languageStr = toJavaStringNode.execute(language); | ||
String codeStr = toJavaStringNode.execute(code); | ||
|
||
Source source = Source.newBuilder(languageStr, codeStr, "<interactive>").build(); |
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.
What's the purpose of the "<interactive>"
here?
.getMessager() | ||
.printMessage( | ||
Diagnostic.Kind.ERROR, | ||
"Argument must not be typed as Thunk. Use @Suspend instead.", |
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.
This error is a touch unclear. From above it looks like you have to go @Suspend Object foo
, not just @Suspend foo
.
* Checks whether {@code a} is lexicographically before {@code b}. | ||
* | ||
* @param a the left operand | ||
* @param b the right operant |
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.
* @param b the right operant | |
* @param b the right operand |
* @return whether {@code a} is before {@code b}. | ||
*/ | ||
public static boolean lt(String a, String b) { | ||
return a.compareTo(b) < 0; |
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.
See my above comments about lexicographic ordering.
test/Benchmarks/src/Collections.enso
Outdated
#Bench_Utils.measure (here.sum_list_meta list) "list meta-fold" 1000 10 | ||
#Bench_Utils.measure (list.fold 0 (+)) "list fold" 1000 10 | ||
#Bench_Utils.measure (vec.fold 0 (+)) "vector fold" 1000 10 | ||
#Bench_Utils.measure (vec_decimal.fold 0 (+)) "vector decimal fold" 1000 10 |
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.
I assume these shouldn't be commented out?
Pull Request Description
Implements an ordered map structure.
Implements improvements to simple thunk arguments and the case node logic.
Closes #497.
Important Notes
Small speedups accross all benchmarks. Map is 30% slower than Haskell.
Checklist
Please include the following checklist in your PR: