class FSEvent::ScheduleMerger

schedulemerger.rb — merge multiple schedules

Copyright © 2014 National Institute of Advanced Industrial Science and Technology (AIST)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.

Public Class Methods

new(*schedules) click to toggle source
# File lib/fsevent/schedulemerger.rb, line 19
def initialize(*schedules)
  @q = Depq.new
  schedules.each {|s|
    merge_schedule(s)
  }
end

Public Instance Methods

clear() click to toggle source
# File lib/fsevent/schedulemerger.rb, line 48
def clear
  until @q.empty?
    @q.delete_min
  end
end
first() click to toggle source
# File lib/fsevent/schedulemerger.rb, line 33
def first
  return nil if @q.empty?
  @q.find_min_priority[1]
end
merge_schedule(s) click to toggle source
# File lib/fsevent/schedulemerger.rb, line 26
def merge_schedule(s)
  t = s.shift
  if t
    @q.insert s, t
  end
end
shift() click to toggle source
# File lib/fsevent/schedulemerger.rb, line 38
def shift
  return nil if @q.empty?
  s, t = @q.delete_min_priority
  t2 = s.shift
  if t2
    @q.insert s, t2
  end
  t
end