views:

690

answers:

3

Why does STL work with a comparison function that is strict weak ordering? Why can't it be partial ordering?

+9  A: 

A partial order would not be sufficient to implement some algorithms, such as a sorting algorithm. Since a partially ordered set does not necessarily define a relationship between all elements of the set, how would you sort a list of two items that do not have an order relationship within the partial order?

Greg Hewgill
tsort ;-)
Steve Jessop
Ok, point taken.. :)
Greg Hewgill
A: 

You can implement it for example by combining std::multimap/multiset with own predicate, overriding std::less.

Dewfy
but it is still required to implement strict weak ordering.
jalf
This answer does not seem to be related with the question...
gimpf
+3  A: 

You cannot perform binary search with partial ordering. You cannot create a binary search tree with partial ordering. What functions/datatypes from algorithm need ordering and can work with partial ordering?

Tadeusz Kopec