
9 Apr
2010
9 Apr
'10
4:44 a.m.
AMDG Dan Larkin wrote:
*x = newValue; update(x);
Or, perhaps some more complex structure that would drive my point home a bit more effectively:
x->field[999] = newValue; update(x);
As long as the library is explicit about the fact that updating data will temporarily void the heap property until an update() call is made on the data in question, it should work much better this way.
This is dubious W.R.T. exception safety, because if anything between the change of the value and the call to update throws or if update itself throws, the invariants of the heap will be broken. In Christ, Steven Watanabe