Class: TimestampQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/timestamp_queue.rb

Instance Method Summary collapse

Constructor Details

#initializeTimestampQueue

Returns a new instance of TimestampQueue.



4
5
6
# File 'lib/timestamp_queue.rb', line 4

def initialize
  @queue = MultiRBTree.new
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/timestamp_queue.rb', line 27

def empty?
  @queue.empty?
end

#find(which, params = nil) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/timestamp_queue.rb', line 19

def find( which, params=nil )
  if which == :first
    _find_first( params )
  elsif which == :all
    _find_all( params )
  end
end

#insert(key, params = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/timestamp_queue.rb', line 8

def insert( key, params=nil )
  ts = nil
  if ( params.is_a?( Hash ) ) &&
     ( params.has_key?( :timestamp ) )
    ts = params[:timestamp]
  else
    ts = _current_time
  end      
  @queue[ts] = key
end