On Tue, 20 Feb 2024 00:30:43 +0000, Farley, Peter <[email protected]> 
wrote:

>My initial purpose is actually part of implementing COBOL-compatible 
>min-heap priority queue functions that return equal-priority nodes 
>in FIFO insert order when popped.  A timestamp or some other monotonically 
>increasing integer tie-breaker

For those that mentioned DB2, I believe the GENERATE_UNIQUE() function produces 
a timestamp that is unique across the SYSPLEX.

As for implementing a heap, you say you don't care if it's a timestamp. Since 
heaps require single thread or a locking mechanism when elements are added / 
removed, why not just have a counter associated with the heap. Each time you 
add an element, you increment (or decrement) the counter and append it to the 
key (in your case priority). Alternatively if you prefer timestamp, then 
maintain the timestamp as the first part of the counter and increment it with 
matching timestamps or replace count with new timestamp & 0.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to