Class: Bio::AssemblyGraphAlgorithms::SingleCoherentPathsBetweenNodesFinder::DualStack

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

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ DualStack

Returns a new instance of DualStack.



347
348
349
350
351
# File 'lib/assembly/single_coherent_paths_between_nodes.rb', line 347

def initialize(&block)
  @checker = block
  @stack = DS::Stack.new
  @dual_stack = DS::Stack.new
end

Instance Method Details

#popObject



361
362
363
# File 'lib/assembly/single_coherent_paths_between_nodes.rb', line 361

def pop
  @stack.pop || @dual_stack.pop
end

#push(to_push) ⇒ Object



353
354
355
356
357
358
359
# File 'lib/assembly/single_coherent_paths_between_nodes.rb', line 353

def push to_push
  if @checker.call to_push
    @dual_stack.push to_push
  else
    @stack.push to_push
  end
end

#sizesObject



365
366
367
# File 'lib/assembly/single_coherent_paths_between_nodes.rb', line 365

def sizes
  return @stack.size, @dual_stack.size
end