class PrettyPrint::GroupQueue

Public Class Methods

new(*groups) click to toggle source
# File lib/prettyprint.rb, line 329
def initialize(*groups)
  @queue = []
  groups.each {|g| enq g}
end

Public Instance Methods

delete(group) click to toggle source
# File lib/prettyprint.rb, line 355
def delete(group)
  @queue[group.depth].delete(group)
end
deq() click to toggle source
# File lib/prettyprint.rb, line 340
def deq
  @queue.each {|gs|
    (gs.length-1).downto(0) {|i|
      unless gs[i].breakables.empty?
        group = gs.slice!(i, 1).first
        group.break
        return group
      end
    }
    gs.each {|group| group.break}
    gs.clear
  }
  return nil
end
enq(group) click to toggle source
# File lib/prettyprint.rb, line 334
def enq(group)
  depth = group.depth
  @queue << [] until depth < @queue.length
  @queue[depth] << group
end