Skip to content

Use custom orderings with heaps and nlargest/nsmallest - #673

Merged
oxinabox merged 8 commits into
JuliaCollections:masterfrom
jlumpe:heaps-custom-ordering
Sep 13, 2020
Merged

oxinabox merged 8 commits into
JuliaCollections:masterfrom
jlumpe:heaps-custom-ordering

Conversation

@jlumpe

@jlumpe jlumpe commented Sep 1, 2020

Copy link
Copy Markdown
Contributor
  • Added constructors to BinaryHeap and MutableBinaryHeap that take a Base.Ordering instance as the first argument. Previously the only way to use a specific ordering was as a type parameter, which only works if the ordering type is a singleton/has a constructor with no arguments.
  • Modified nlargest and nsmallest signatures to take by and lt arguments as in sort. This shouldn't incur a performance penalty as I'm pretty sure Julia can fully specialize on keyword arguments, and the default argument values should statically resolve to calling nextreme with either Base.Forward or Base.Reverse.
  • Updated docs page with instructions on how to use these features.

@oxinabox

oxinabox commented Sep 8, 2020

Copy link
Copy Markdown
Member

LGTM.
Can you change the version in the Project.toml (increment the last digit) so can tag a release?

@jlumpe

jlumpe commented Sep 10, 2020

Copy link
Copy Markdown
Contributor Author

Done!

Comment thread Project.toml Resolved
@oxinabox
oxinabox merged commit db6c845 into JuliaCollections:master Sep 13, 2020
@nsajko nsajko mentioned this pull request Oct 9, 2026
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

Successfully merging this pull request may close these issues.

2 participants