Home » Community » Coffee corner » Quiz #5
Re: Quiz #5 [message #57913 is a reply to message #57912] |
Tue, 28 December 2021 03:04 |
Lance
Messages: 527 Registered: March 2007
|
Contributor |
|
|
It's good to understand the logic the system used to order Ctrls. So I copy the Predicate herebool RectLess(const Rect& a, const Rect& b)
{
int d = min(a.bottom, b.bottom) - max(a.top, b.top);
int w = min(a.GetHeight(), b.GetHeight());
return d > w / 2 ? a.left < b.left : a.top < b.top;
}
If the height of common vertical part is over half of height of the shorter ctrs, compare horizontally, otherwise , compare vertically.
Given any two Ctrls, the predicate is deterministic. Is this predicate not transitive, ie. a<b, b<c doesn't imply a<c? What if we pass the predicate to a quicksort like algorithm?
[Updated on: Tue, 28 December 2021 03:05] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon May 13 13:55:02 CEST 2024
Total time taken to generate the page: 0.01865 seconds
|