Conversation
|
@StephenVavasis, here are a few definitions to bring more parity with |
Codecov Report
@@ Coverage Diff @@
## master #264 +/- ##
==========================================
+ Coverage 95.86% 95.86% +<.01%
==========================================
Files 30 30
Lines 2223 2493 +270
==========================================
+ Hits 2131 2390 +259
- Misses 92 103 +11
Continue to review full report at Codecov.
|
|
Yes, this looks good. Please go ahead and merge. |
|
Is a corresponding |
|
Actually, now that I think about this, there are some pitfalls here that could trip up a user. Suppose S = {"ABC", "abc", and "def"}, and the usual lex comparison is used to define S. Suppose that T = {"ABC", "DEF", and "GHI"} and a case-insensitive lex comparison is used to define T. In this somewhat pathological example, the test The sorted containers have the feature of a user-specified ordering of keys, which means that two keys can be equal for the purpose of the container even though they are unequal according to the rest of Julia. This means that the sorted containers do not necessarily play nicely with other aspects of Julia. |
|
@StephenVavasis, thanks for the review and example! It is complicated when dealing with something like case-insensitivity (or other criteria where two keys can be equal according to the ordering, but not with A few thoughts:
I'm leaning towards ii. and iii. @KristofferC, I guess a |
|
I think (ii) and (iii) should be fine. I think the following will work: The implementation of == should first compare order objects; if they are equal then the current code is fine. If they are unequal, then the two sorted sets should be converted to Set (I think the built-in constructor in set.jl will handle this without change since it can already build a Set from an iterable), and then the two resulting Base.Set items should be compared. There is already an isequal() function inside sorted_set.jl. I don't recall exactly what is the default relationship between == and isequal(), but in any case, we should make them consistent. With regard to hashing a SortedDict, there is no way to be consistent with both (ii) and (iii). However, attaining consistency with (iii) is relatively straightforward, namely, first convert the SortedSet to a Set, and then hash the resulting Set. On a different note: when I first wrote SortedSet, there was no AbstractSet available, but now I see that it is available in 0.5. So SortedSet should really be a subtype of AbstractSet. In 0.5 there don't seem to be any default methods for AbstractSet, but maybe these are coming in future releases. |
|
I was just reading up on the ]C++ behavior with regard to sorted containers [1,2]. Java seems to There, comparison in sorted containers (e.g., standard I'm wondering if we should make the same choice. Java seems to have done so. [1] http://stackoverflow.com/questions/8217588/equality-evaluation-in-associative-containers-stl |
|
Kevin, what you have described is already how the sorted containers work. However, it doesn't seem to clarify how to deal with == between two distinct sorted containers, or how to hash the sorted containers. |
|
@StephenVavasis, I was thinking that this would provide an alternative to the current implementation (of equality). But I think you're right, I don't think it clarifies much, if anything. |
08fa8b4 to
da5c2ef
Compare
|
@StephenVavasis wrote:
This means that
Some ideas:
Thoughts? |
da5c2ef to
041dabd
Compare
* Based on definition for base.Set * Also defined <, <=, ⊊, and ⊈
041dabd to
36e88ec
Compare
Base.SetBase.Set