Class: Hamster::MutableQueue Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hamster/experimental/mutable_queue.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hamster::ReadCopyUpdate

Class Method Details

.[](*items) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
# File 'lib/hamster/experimental/mutable_queue.rb', line 9

def self.[](*items)
  MutableQueue.new(Deque[*items])
end

Instance Method Details

#dequeueObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


17
18
19
20
21
22
23
24
# File 'lib/hamster/experimental/mutable_queue.rb', line 17

def dequeue
  head = nil
  transform do |queue|
    head = queue.head
    queue.dequeue
  end
  head
end

#enqueue(item) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


13
14
15
# File 'lib/hamster/experimental/mutable_queue.rb', line 13

def enqueue(item)
  transform { |queue| queue.enqueue(item) }
end