lib/hamster/queue.rb in hamster-1.0.1.pre.rc.1 vs lib/hamster/queue.rb in hamster-1.0.1.pre.rc2
- old
+ new
@@ -36,10 +36,12 @@
def enqueue(item)
transform { @rear = @rear.cons(item) }
end
def_delegator :self, :enqueue, :<<
def_delegator :self, :enqueue, :add
+ def_delegator :self, :enqueue, :conj
+ def_delegator :self, :enqueue, :conjoin
def dequeue
front = @front
rear = @rear
if front.empty?
@@ -64,23 +66,20 @@
to_list.eql?(other.to_list)
end
def_delegator :self, :eql?, :==
def to_a
- to_list.to_a
+ @front.to_a.concat(@rear.to_a.tap { |a| a.reverse! })
end
def_delegator :self, :to_a, :entries
+ def_delegator :self, :to_a, :to_ary
- def to_ary
- to_list.to_ary
- end
-
def to_list
@front.append(@rear.reverse)
end
def inspect
- to_list.inspect
+ to_a.inspect
end
end
EmptyQueue = Hamster::Queue.new
end