-
Notifications
You must be signed in to change notification settings - Fork 347
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
A Library of Binary Tree Algorithms as Mixable Scala Traits #496
Conversation
Actually I'm going to tweak this a little, it causes some subtle problems when I try to apply it to |
@@ -1,9 +1,8 @@ | |||
language: scala | |||
sudo: false | |||
matrix: |
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.
why is this change in here? other than the compile step being before the test step whats the gain/reasoning?
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.
The test was timing out. Factoring out the compilation helps keep the actual 'sbt test' command from running too long. This used to be a separate commit with its own message, but it was all squashed when I refactored the PR
@ianoc I replaced |
new Inject[K, V](keyOrdering, valueMonoid) with INodeInc[K, V] with IncrementMap[K, V] { | ||
// INode[K] | ||
val color = clr | ||
val lsub = ls.asInstanceOf[NodeInc[K, V]] |
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.
why the casts here? Why not accept NodeInc[K, V]
as the type for ls
? same for the rest.
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.
Can you put a return type on iNode
. What are we using here?
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.
iNode
is an abstract function defined in ...redblack.tree.Node
(the very top of the hierarchy). Its return type is INode
(the highest level internal tree node type). At that level, it has no knowledge of any sub classes, and so ls
and rs
have to be Node
, and therefore they need to be cast. I also would have preferred not to require casting, but could not discover any way around it. I decided it was at least (a) localized and (b) only relevant to anybody designing a new tree/map subclass.
…ith specific classes that inherit from the hierarchy which interact badly with type-widening
81f8789
to
62505f4
Compare
@johnynek, replacing |
@johnynek @ianoc @avibryant |
This is now available here: So I'm going to close this out |
This is a PR for tree and map traits supporting some binary tree algorithms, factored out of the PR for implementing t-digest: #495
A Library of Binary Tree Algorithms as Mixable Scala Traits
http://erikerlandson.github.io/blog/2015/09/26/a-library-of-binary-tree-algorithms-as-mixable-scala-traits/