Heap.Update (gb.data)
Sub Update ( Old As Variant, New As Variant )
Find all occurences of
Old' and replace them by
New'. This is an O(n)
operation. Additionally the heap has to be rebuilt as soon as there is
more than one replacement made.
If
New' is Null, then the entry will be deleted.
Missing closing '`'
The search for objects is done by identity and
not by using the
_compare() method. "By identity" means that if two objects are to be
compared and both have a special _identity() method returning a Variant,
the return values of these methods are compared.
If one of the objects does not implement the _identity() method, the
default is comparison by object addresses in memory. This strategy lets
you save primitive data types (Integer, Boolean, String), etc. in the
heap. But you can also
distinct objects in equivalence classes. The
_compare() method defines your equivalence relation, the identity
comparison enables to discern different objects.
If we are a heap of objects whose _compare() methods compare some sort of
priority, and
Old' is the same object as
New', this can be used to
propagate a priority change made to the object and will correct its
position in the heap.
This has an application in Dijkstra's algorithm (or any priority first
search like Prim or A*) where you would update a node's priority.