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

Order.reverseOrder Should tie the knot #870

Closed
NightRa opened this issue Dec 26, 2014 · 4 comments
Closed

Order.reverseOrder Should tie the knot #870

NightRa opened this issue Dec 26, 2014 · 4 comments

Comments

@NightRa
Copy link

NightRa commented Dec 26, 2014

Order.reverseOrder.reverseOrder should result in the original order instance.
(It actually is one of the performance bottlenecks in my application right now)
It may also override the other methods in Order - as lessThan, greaterThan and the others,
As computing the ordering is usually more expensive than calling the appropriate comparison function directly.

@markfarrell
Copy link
Contributor

Hmm, is there perhaps a better way to pass around the original Order instance in your application, rather than change the behaviour of Order.reverseOrder.reverseOrder? I'm not knowledgable enough right now to propose a better solution, but leaving Order alone is my initial reaction to this issue.

@NightRa
Copy link
Author

NightRa commented Dec 28, 2014

@markfarrell I'm alternating between Order and Order.reverseOrder.
It gives a beautiful solution, being able to write a piece of code once and give it different orders.
For example, write minimum, and maximum is derived from that.
I'm using it to alternate min and max levels in a minimax tree, without the need to write 2 functions or pass a boolean parameter 'isMax'.

@stew
Copy link
Contributor

stew commented Dec 29, 2014

seems like it wouldn't be hard to override reverseOrder in the anonymous instance created by reverseOrder to return self

xuwei-k added a commit that referenced this issue Jul 27, 2015
Issue #870: Made Order.reverseOrder tie the knot.
@xuwei-k
Copy link
Member

xuwei-k commented Aug 7, 2015

#956

@xuwei-k xuwei-k closed this as completed Aug 7, 2015
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

4 participants