I am looking for a data structure that can do range-sums like a Segment tree but can support adding a new piece of data at any time without rebuilding the entire tree. I believe I can hack together a segment which can handle adding new data dynamically but it wouldn't be pretty.
If it helps, I will always be "appending" data since it is time based.
Example:
Order[time=0, quantity=1]
Order[time=1, quantity=2]
Order[time=2, quantity=4]
Order[time=3, quantity=2]
Range sum segment Tree:
sum[0->3=9]
sum[0->1=3] sum[2->3=6]
time0=1 time1=2 time2=4 time3=2
What would happen to the tree above if I added Order[time=4, quantity=3]
sum[0->4=12]
sum[0->3=9] sum[4->4=3]
sum[0->1=3] sum[2->3=6] sum[4->4=3]
time0=1 time1=2 time2=4 time3=2 time4=3
I can certainly use the approach above but I am hoping there is something better.