17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/packet/timer_store.rb', line 17
def store(timer)
int_time = timer.scheduled_time.to_i
@container[int_time] ||= []
@container[int_time] << timer
if @container.empty? or @order.empty?
@order << int_time
return
end
if @order.last <= int_time
@order << int_time
else
index = bin_search_for_key(0,@order.length - 1,int_time)
if(int_time < @order[index-1] && index != 0)
@order.insert(index-1,int_time)
else
@order.insert(index,int_time)
end
end
end
|