Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
@JDługosz: You are correct. Regular bool won't help as it can hold only two states. But we can use std optional<bool>. Or enum class will three values.
@MartinR: There is an assumption that overlapping segments will be merged during sanitization step before calling into check_loop. So in your example, input should become (3, 0) -> (3, 1) ->(0, 1)->(0, 0)->(3, 0). It will become a loop.
Caller of CreateNode should send correctly populated nodedata as void*. It means caller will create TimerInfo, set refTime and pass this as void* to CreateNode. CreateNode needn't look inside nodedata.
@xyf: Purpose of priority queue is to give nodes based on increasing/decreasing priority. But priority is not defined by queue. It is property of nodedata. So, priority queue will need a comparator to come up with sorted order. Comaprator may know all relevant details about nodedata and its internal properties. So in current example, comparator needs to know about expiry time and priority value (Because if expiry time is same, we pick timer based on priority).