JuliaCollections / DataStructures.jl

Julia implementation of Data structures
https://juliacollections.github.io/DataStructures.jl/latest/
MIT License
689 stars 243 forks source link

Update ordered_containers.md #870

Open SyxP opened 1 year ago

SyxP commented 1 year ago

1) Fixed incorrect example code in OrderedSet (Note that this code doesn't run as the various irrational numbers are not defined. Previously it was just a method error.)

2) Added clarification on equality. The behaviour was raised as a point of confusion in a Slack thread. I just documented the current existing behaviour.

jariji commented 1 year ago

This is documenting rather than fixing bad behavior IMO.

For any type T, x::T and y::T should not have x == y unless x and y agree on all aspects of their public API. Since order is part of the public API of Ordered containers, they should not be ==(::T, ::T) unless they agree on order.

SyxP commented 1 year ago

I agree, I don't like how this works. But as we had a discussion on Slack, this is actually how someone might prefer the behaviour to be.

I make no judgement on whether this is the "correct" behaviour. But as of now this is what is inside the library, and I document it to prevent confusion. I will close the PR if there is another successfully merged PR augmenting the behaviour.

StephenVavasis commented 1 year ago

I don't think ordered_set is part of this repository. I believe that it is in the JuliaCollections/OrderedCollections.jl repository.