Skip to content

Commit

Permalink
Improve documentation of #each* methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mhib committed Feb 4, 2023
1 parent 6ebd5e9 commit 375465c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/pairing_heap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def get_priority_if_exists(elem)

# Returns enumerator of elements.
# @note There are no order guarantees.
# @yieldparam [Object] element Element in the heap
# @return [Enumerator<Object>]
def each
return to_enum(__method__) { size } unless block_given?
Expand All @@ -268,7 +269,8 @@ def each

# Returns enumerator of elements.
# @note There are no order guarantees.
# @return [Enumerator<Array(Object, Object)>]
# @return [Enumerator<Array(Object, Object)>] if no block given
# @yieldparam [Array(Object, Object)] element Element in the heap with its priority
def each_with_priority
return to_enum(__method__) { size } unless block_given?
@nodes.each_value { |node| yield [node.elem, node.priority] }
Expand Down Expand Up @@ -407,13 +409,15 @@ def pop_with_priority

# Returns enumerator of elements.
# @note There are no order guarantees.
# @return [Enumerator]
# @yieldparam [Object] element element in the heap
# @return [Enumerator<Object>] if no block given
def each
return to_enum(__method__) { size } unless block_given?
NodeVisitor.visit_node(@root) { |x| yield x.elem }
end

# @return [Enumerator<Array(object, object)>]
# @return [Enumerator<Array(Object, Object)>] if no block given
# @yieldparam [Array(Object, Object)] element Element in the heap with its priority
# Returns enumerator of elements.
# @note There are no order guarantees.
def each_with_priority
Expand Down

0 comments on commit 375465c

Please sign in to comment.