Class: GraphLab::Queue
- Inherits:
-
Object
- Object
- GraphLab::Queue
- Defined in:
- lib/graphlab.rb
Instance Attribute Summary collapse
-
#drawing ⇒ Object
Struct object to store the attributes of the drawn visualization.
-
#items ⇒ Object
readonly
array used to store the values in the queue.
Instance Method Summary collapse
-
#dequeue ⇒ Object
dequeue method.
-
#enqueue(value) ⇒ Object
enqueue method.
-
#initialize ⇒ Queue
constructor
class constructor.
-
#inspect ⇒ Object
return a string representation of the array.
- #isEmpty? ⇒ Boolean
-
#peek ⇒ Object
peek method.
-
#to_s ⇒ Object
returns a string representation of the array.
Constructor Details
#initialize ⇒ Queue
class constructor
455 456 457 |
# File 'lib/graphlab.rb', line 455 def initialize @items = Array.new end |
Instance Attribute Details
#drawing ⇒ Object
Struct object to store the attributes of the drawn visualization
452 453 454 |
# File 'lib/graphlab.rb', line 452 def drawing @drawing end |
#items ⇒ Object (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
#dequeue ⇒ Object
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 |
#inspect ⇒ Object
return a string representation of the array
486 487 488 |
# File 'lib/graphlab.rb', line 486 def inspect return to_s end |
#isEmpty? ⇒ 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 |
#peek ⇒ Object
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_s ⇒ Object
returns a string representation of the array
491 492 493 |
# File 'lib/graphlab.rb', line 491 def to_s return @items.inspect end |