-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add OrderedSet class to standard lib #257
Conversation
The |
If so, I'd suggest removing the native implementation. The stdlib is easier to maintain. Agree? |
@kaeluka: |
When the warning system is in place, we could mark |
I agree with removing build-in implementations. |
Ok, so if this is has passed review (has it?), I suggest we wait for plenary to be merged, then I'll rebase this on top of the new master. |
I only saw the Would you separate |
-- | ||
-- Takes a binary relation that returns true if the first argument should go | ||
-- left of the second argument and a binary relation that is used as equality | ||
-- for elements. |
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 seems like a break of abstraction. goesLeft
reveals that OrderedSet
uses a tree internally. I suggest replacing cmp
and goesLeft
by a strcmp
like return value (and then moving to something enum
y when we have support for this).
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.
will do
@EliasC: I reacted to your inline comments and the leak of abstraction issue. Pulling out |
It would be good to also update the existing tests that use |
That has nothing to do with the Assert lib. Should be a separate PR. |
I would say changing test cases to use the Assert lib has something to do with the Assert lib, but let's leave it for a later PR anyway. |
There's one thing in the iterator interface I would like to fix. Consider the following program:
In the last loop, |
If you're not going to separate the |
Sure, if you show me how! :) |
Will do! :) |
Please put it in a PR of its own. I went hunting for it this morning and could not find it, because I was not expecting to find it hidden in something labelled "ordered set". |
I'll do that when I'll get around to it, after OOPSLA most likely. |
On a related note. There are 80+ uses of assertFalse and assertTrue in the stdlib tests. That will need refactoring before we remove anything. I am not a huge fan of removing something which has more features so casually. |
See discussion above! |
I now removed the assert lib from this PR. |
@EliasC: Is there anything missing now? |
It feels odd to deviate from the main stream approaches Java and C# on this well-understood concept. Making for-loop to support enumerable or iterable natively ( An pragmatic approach seems to use the Java convention ( |
An ordered set is based on a binary tree. This implementation is not balanced yet.
This looks good now! Will merge next time I see it :) |
Add OrderedSet class to standard lib
It's based on a binary tree, moderately well tested, not optimised.