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
2009-08-18 11:25:32
tsort ;-)
Steve Jessop
2009-08-18 13:43:49
Ok, point taken.. :)
Greg Hewgill
2009-08-18 21:08:00
A:
You can implement it for example by combining std::multimap/multiset with own predicate, overriding std::less.
Dewfy
2009-08-18 11:30:04
+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
2009-08-18 14:36:53