@@ -82,31 +82,35 @@ The following functions are provided:
8282 on the heap.
8383
8484
85+ For max heaps, the reverse of a heap, the following functions are provided:
86+
87+
8588.. function :: heapify_max(x)
8689
87- Transform list *x * into a heap, in-place, in linear time.
90+ Transform list *x * into a max heap, in-place, in linear time.
8891
8992 .. versionadded :: next
9093
9194
9295.. function :: heappush_max(heap, item)
9396
94- Push the value *item * onto the *heap *, maintaining the heap invariant.
97+ Push the value *item * onto the max *heap *, maintaining the heap invariant.
9598
9699 .. versionadded :: next
97100
101+
98102.. function :: heappop_max(heap)
99103
100- Pop and return the largest item from the *heap *, maintaining the heap
101- invariant. If the heap is empty, :exc: `IndexError ` is raised. To access the
104+ Pop and return the largest item from the max *heap *, maintaining the heap
105+ invariant. If the max heap is empty, :exc: `IndexError ` is raised. To access the
102106 largest item without popping it, use ``heap[0] ``.
103107
104108 .. versionadded :: next
105109
106110
107111.. function :: heappushpop_max(heap, item)
108112
109- Push *item * on the heap, then pop and return the largest item from the
113+ Push *item * on the max heap, then pop and return the largest item from the max
110114 *heap *. The combined action runs more efficiently than :func: `heappush_max `
111115 followed by a separate call to :func: `heappop_max `.
112116
@@ -115,17 +119,17 @@ The following functions are provided:
115119
116120.. function :: heapreplace_max(heap, item)
117121
118- Pop and return the largest item from the *heap *, and also push the new *item *.
119- The heap size doesn't change. If the heap is empty, :exc: `IndexError ` is raised.
122+ Pop and return the largest item from the max *heap *, and also push the new *item *.
123+ The max heap size doesn't change. If the max heap is empty, :exc: `IndexError ` is raised.
120124
121- This one step operation is more efficient than a :func: `heappop ` followed by
122- :func: `heappush ` and can be more appropriate when using a fixed-size heap.
125+ This one step operation is more efficient than a :func: `heappop_max ` followed by
126+ :func: `heappush_max ` and can be more appropriate when using a fixed-size heap.
123127 The pop/push combination always returns an element from the heap and replaces
124128 it with *item *.
125129
126130 The value returned may be larger than the *item * added. If that isn't
127- desired, consider using :func: `heappushpop ` instead. Its push/pop
128- combination returns the smaller of the two values, leaving the larger value
131+ desired, consider using :func: `heappushpop_max ` instead. Its push/pop
132+ combination returns the larger of the two values, leaving the smaller value
129133 on the heap.
130134
131135 .. versionadded :: next
0 commit comments