1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(_heapq_heappush__doc__,
6 "heappush($module, heap, item, /)\n"
7 "--\n"
8 "\n"
9 "Push item onto heap, maintaining the heap invariant.");
10 
11 #define _HEAPQ_HEAPPUSH_METHODDEF    \
12     {"heappush", (PyCFunction)(void(*)(void))_heapq_heappush, METH_FASTCALL, _heapq_heappush__doc__},
13 
14 static PyObject *
15 _heapq_heappush_impl(PyObject *module, PyObject *heap, PyObject *item);
16 
17 static PyObject *
_heapq_heappush(PyObject * module,PyObject * const * args,Py_ssize_t nargs)18 _heapq_heappush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
19 {
20     PyObject *return_value = NULL;
21     PyObject *heap;
22     PyObject *item;
23 
24     if (!_PyArg_CheckPositional("heappush", nargs, 2, 2)) {
25         goto exit;
26     }
27     heap = args[0];
28     item = args[1];
29     return_value = _heapq_heappush_impl(module, heap, item);
30 
31 exit:
32     return return_value;
33 }
34 
35 PyDoc_STRVAR(_heapq_heappop__doc__,
36 "heappop($module, heap, /)\n"
37 "--\n"
38 "\n"
39 "Pop the smallest item off the heap, maintaining the heap invariant.");
40 
41 #define _HEAPQ_HEAPPOP_METHODDEF    \
42     {"heappop", (PyCFunction)_heapq_heappop, METH_O, _heapq_heappop__doc__},
43 
44 PyDoc_STRVAR(_heapq_heapreplace__doc__,
45 "heapreplace($module, heap, item, /)\n"
46 "--\n"
47 "\n"
48 "Pop and return the current smallest value, and add the new item.\n"
49 "\n"
50 "This is more efficient than heappop() followed by heappush(), and can be\n"
51 "more appropriate when using a fixed-size heap.  Note that the value\n"
52 "returned may be larger than item!  That constrains reasonable uses of\n"
53 "this routine unless written as part of a conditional replacement:\n"
54 "\n"
55 "    if item > heap[0]:\n"
56 "        item = heapreplace(heap, item)");
57 
58 #define _HEAPQ_HEAPREPLACE_METHODDEF    \
59     {"heapreplace", (PyCFunction)(void(*)(void))_heapq_heapreplace, METH_FASTCALL, _heapq_heapreplace__doc__},
60 
61 static PyObject *
62 _heapq_heapreplace_impl(PyObject *module, PyObject *heap, PyObject *item);
63 
64 static PyObject *
_heapq_heapreplace(PyObject * module,PyObject * const * args,Py_ssize_t nargs)65 _heapq_heapreplace(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
66 {
67     PyObject *return_value = NULL;
68     PyObject *heap;
69     PyObject *item;
70 
71     if (!_PyArg_CheckPositional("heapreplace", nargs, 2, 2)) {
72         goto exit;
73     }
74     heap = args[0];
75     item = args[1];
76     return_value = _heapq_heapreplace_impl(module, heap, item);
77 
78 exit:
79     return return_value;
80 }
81 
82 PyDoc_STRVAR(_heapq_heappushpop__doc__,
83 "heappushpop($module, heap, item, /)\n"
84 "--\n"
85 "\n"
86 "Push item on the heap, then pop and return the smallest item from the heap.\n"
87 "\n"
88 "The combined action runs more efficiently than heappush() followed by\n"
89 "a separate call to heappop().");
90 
91 #define _HEAPQ_HEAPPUSHPOP_METHODDEF    \
92     {"heappushpop", (PyCFunction)(void(*)(void))_heapq_heappushpop, METH_FASTCALL, _heapq_heappushpop__doc__},
93 
94 static PyObject *
95 _heapq_heappushpop_impl(PyObject *module, PyObject *heap, PyObject *item);
96 
97 static PyObject *
_heapq_heappushpop(PyObject * module,PyObject * const * args,Py_ssize_t nargs)98 _heapq_heappushpop(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
99 {
100     PyObject *return_value = NULL;
101     PyObject *heap;
102     PyObject *item;
103 
104     if (!_PyArg_CheckPositional("heappushpop", nargs, 2, 2)) {
105         goto exit;
106     }
107     heap = args[0];
108     item = args[1];
109     return_value = _heapq_heappushpop_impl(module, heap, item);
110 
111 exit:
112     return return_value;
113 }
114 
115 PyDoc_STRVAR(_heapq_heapify__doc__,
116 "heapify($module, heap, /)\n"
117 "--\n"
118 "\n"
119 "Transform list into a heap, in-place, in O(len(heap)) time.");
120 
121 #define _HEAPQ_HEAPIFY_METHODDEF    \
122     {"heapify", (PyCFunction)_heapq_heapify, METH_O, _heapq_heapify__doc__},
123 
124 PyDoc_STRVAR(_heapq__heappop_max__doc__,
125 "_heappop_max($module, heap, /)\n"
126 "--\n"
127 "\n"
128 "Maxheap variant of heappop.");
129 
130 #define _HEAPQ__HEAPPOP_MAX_METHODDEF    \
131     {"_heappop_max", (PyCFunction)_heapq__heappop_max, METH_O, _heapq__heappop_max__doc__},
132 
133 PyDoc_STRVAR(_heapq__heapreplace_max__doc__,
134 "_heapreplace_max($module, heap, item, /)\n"
135 "--\n"
136 "\n"
137 "Maxheap variant of heapreplace.");
138 
139 #define _HEAPQ__HEAPREPLACE_MAX_METHODDEF    \
140     {"_heapreplace_max", (PyCFunction)(void(*)(void))_heapq__heapreplace_max, METH_FASTCALL, _heapq__heapreplace_max__doc__},
141 
142 static PyObject *
143 _heapq__heapreplace_max_impl(PyObject *module, PyObject *heap,
144                              PyObject *item);
145 
146 static PyObject *
_heapq__heapreplace_max(PyObject * module,PyObject * const * args,Py_ssize_t nargs)147 _heapq__heapreplace_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
148 {
149     PyObject *return_value = NULL;
150     PyObject *heap;
151     PyObject *item;
152 
153     if (!_PyArg_CheckPositional("_heapreplace_max", nargs, 2, 2)) {
154         goto exit;
155     }
156     heap = args[0];
157     item = args[1];
158     return_value = _heapq__heapreplace_max_impl(module, heap, item);
159 
160 exit:
161     return return_value;
162 }
163 
164 PyDoc_STRVAR(_heapq__heapify_max__doc__,
165 "_heapify_max($module, heap, /)\n"
166 "--\n"
167 "\n"
168 "Maxheap variant of heapify.");
169 
170 #define _HEAPQ__HEAPIFY_MAX_METHODDEF    \
171     {"_heapify_max", (PyCFunction)_heapq__heapify_max, METH_O, _heapq__heapify_max__doc__},
172 /*[clinic end generated code: output=37ef2a3319971c8d input=a9049054013a1b77]*/
173