I have a list of objects that have durations,
ProcedurePart
Start: double
Stop: double
Instructions: string
they occur sequentially after each other:
stepOne stepTwo stepThree
Start: 0.0 Start: 1.56 Start: 5.443
Stop: 1.56 Stop: 5.443 Stop: 10.9
"Take the dinglebop" "Smooth it with shleem" "Push it through the gru...
I want to pull out items using a timestamp, the item retrieved should be the step within which that timestamp falls.
E.g., for the above sequence:
sequence[0.0] = stepOne
sequence[1.0] = stepOne
sequence[1.56] = stepTwo
sequence[2.578281] = stepTwo
sequence[10.0] = stepThree
The precision is only limited by the data-type (C#'s double
), and because times are continuous I can't create a look-up table using all possible discrete input values.
Is there a data structure that can store this sequence and allow for anything better than O(log(N)) look-up times (better than binary search)?
DateTime
instead ofdouble
, maybe with a custom comparator?