c++ - Create function that calculates a boolean return value for a given (floating point) time value based on edge transitions -


i want create function (in c++) return true or false given floating point time value. true or false return value needs determined based on data set of true->false , false->true transition events have occurred @ specific times.

i create array of of transition events based on dataset , compare every single 1 of them given time value find recent event precedes given time, seems horribly inefficient. there better way this? maybe sort of binary search? other problem dataset of transition events continuously updated on time , can't guarantee updates received in order (although have accurate timestamps associated them).

step 1: sort events timestamp, o(n log n).

step 2: given time, search interval contains it; binary search o(log n).

step 3: if transition @ beginning of interval t->f, answer false; if f->t, answer true. (for times before first event, @ first event , guess.)


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -