Class: GraphLab::Queue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQueue

class constructor



455
456
457
# File 'lib/graphlab.rb', line 455

def initialize
	@items = Array.new
end

Instance Attribute Details

#drawingObject

Struct object to store the attributes of the drawn visualization



452
453
454
# File 'lib/graphlab.rb', line 452

def drawing
  @drawing
end

#itemsObject (readonly)

array used to store the values in the queue



450
451
452
# File 'lib/graphlab.rb', line 450

def items
  @items
end

Instance Method Details

#dequeueObject

dequeue method. if a drawing exists, redraw the canvas



460
461
462
463
464
465
466
# File 'lib/graphlab.rb', line 460

def dequeue
	value = items.shift
	if @drawing
		view_queue(self, false)
	end
	return value
end

#enqueue(value) ⇒ Object

enqueue method. if a drawing exists, redraw the canvas



477
478
479
480
481
482
483
# File 'lib/graphlab.rb', line 477

def enqueue(value)
	output = items << value
	if @drawing
		view_queue(self, false)
	end
	return output
end

#inspectObject

return a string representation of the array



486
487
488
# File 'lib/graphlab.rb', line 486

def inspect
	return to_s
end

#isEmpty?Boolean

Returns:

  • (Boolean)


495
496
497
498
499
500
501
# File 'lib/graphlab.rb', line 495

def isEmpty?
	output = false
	if(@items.size == 0)
		output = true
	end
	return output
end

#peekObject

peek method. if a drawing exists, redraw the canvas



469
470
471
472
473
474
# File 'lib/graphlab.rb', line 469

def peek
	if @drawing
		view_queue(self, true)
	end
	return items.first
end

#to_sObject

returns a string representation of the array



491
492
493
# File 'lib/graphlab.rb', line 491

def to_s	
	return @items.inspect
end