LCOV - code coverage report
Current view: top level - Modules/clinic - _heapqmodule.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 84 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 8 0.0 %
Branches: 0 40 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(_heapq_heappush__doc__,
      12                 :            : "heappush($module, heap, item, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Push item onto heap, maintaining the heap invariant.");
      16                 :            : 
      17                 :            : #define _HEAPQ_HEAPPUSH_METHODDEF    \
      18                 :            :     {"heappush", _PyCFunction_CAST(_heapq_heappush), METH_FASTCALL, _heapq_heappush__doc__},
      19                 :            : 
      20                 :            : static PyObject *
      21                 :            : _heapq_heappush_impl(PyObject *module, PyObject *heap, PyObject *item);
      22                 :            : 
      23                 :            : static PyObject *
      24                 :          0 : _heapq_heappush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      25                 :            : {
      26                 :          0 :     PyObject *return_value = NULL;
      27                 :            :     PyObject *heap;
      28                 :            :     PyObject *item;
      29                 :            : 
      30   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("heappush", nargs, 2, 2)) {
                   #  # ]
      31                 :          0 :         goto exit;
      32                 :            :     }
      33         [ #  # ]:          0 :     if (!PyList_Check(args[0])) {
      34                 :          0 :         _PyArg_BadArgument("heappush", "argument 1", "list", args[0]);
      35                 :          0 :         goto exit;
      36                 :            :     }
      37                 :          0 :     heap = args[0];
      38                 :          0 :     item = args[1];
      39                 :          0 :     return_value = _heapq_heappush_impl(module, heap, item);
      40                 :            : 
      41                 :          0 : exit:
      42                 :          0 :     return return_value;
      43                 :            : }
      44                 :            : 
      45                 :            : PyDoc_STRVAR(_heapq_heappop__doc__,
      46                 :            : "heappop($module, heap, /)\n"
      47                 :            : "--\n"
      48                 :            : "\n"
      49                 :            : "Pop the smallest item off the heap, maintaining the heap invariant.");
      50                 :            : 
      51                 :            : #define _HEAPQ_HEAPPOP_METHODDEF    \
      52                 :            :     {"heappop", (PyCFunction)_heapq_heappop, METH_O, _heapq_heappop__doc__},
      53                 :            : 
      54                 :            : static PyObject *
      55                 :            : _heapq_heappop_impl(PyObject *module, PyObject *heap);
      56                 :            : 
      57                 :            : static PyObject *
      58                 :          0 : _heapq_heappop(PyObject *module, PyObject *arg)
      59                 :            : {
      60                 :          0 :     PyObject *return_value = NULL;
      61                 :            :     PyObject *heap;
      62                 :            : 
      63         [ #  # ]:          0 :     if (!PyList_Check(arg)) {
      64                 :          0 :         _PyArg_BadArgument("heappop", "argument", "list", arg);
      65                 :          0 :         goto exit;
      66                 :            :     }
      67                 :          0 :     heap = arg;
      68                 :          0 :     return_value = _heapq_heappop_impl(module, heap);
      69                 :            : 
      70                 :          0 : exit:
      71                 :          0 :     return return_value;
      72                 :            : }
      73                 :            : 
      74                 :            : PyDoc_STRVAR(_heapq_heapreplace__doc__,
      75                 :            : "heapreplace($module, heap, item, /)\n"
      76                 :            : "--\n"
      77                 :            : "\n"
      78                 :            : "Pop and return the current smallest value, and add the new item.\n"
      79                 :            : "\n"
      80                 :            : "This is more efficient than heappop() followed by heappush(), and can be\n"
      81                 :            : "more appropriate when using a fixed-size heap.  Note that the value\n"
      82                 :            : "returned may be larger than item!  That constrains reasonable uses of\n"
      83                 :            : "this routine unless written as part of a conditional replacement:\n"
      84                 :            : "\n"
      85                 :            : "    if item > heap[0]:\n"
      86                 :            : "        item = heapreplace(heap, item)");
      87                 :            : 
      88                 :            : #define _HEAPQ_HEAPREPLACE_METHODDEF    \
      89                 :            :     {"heapreplace", _PyCFunction_CAST(_heapq_heapreplace), METH_FASTCALL, _heapq_heapreplace__doc__},
      90                 :            : 
      91                 :            : static PyObject *
      92                 :            : _heapq_heapreplace_impl(PyObject *module, PyObject *heap, PyObject *item);
      93                 :            : 
      94                 :            : static PyObject *
      95                 :          0 : _heapq_heapreplace(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      96                 :            : {
      97                 :          0 :     PyObject *return_value = NULL;
      98                 :            :     PyObject *heap;
      99                 :            :     PyObject *item;
     100                 :            : 
     101   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("heapreplace", nargs, 2, 2)) {
                   #  # ]
     102                 :          0 :         goto exit;
     103                 :            :     }
     104         [ #  # ]:          0 :     if (!PyList_Check(args[0])) {
     105                 :          0 :         _PyArg_BadArgument("heapreplace", "argument 1", "list", args[0]);
     106                 :          0 :         goto exit;
     107                 :            :     }
     108                 :          0 :     heap = args[0];
     109                 :          0 :     item = args[1];
     110                 :          0 :     return_value = _heapq_heapreplace_impl(module, heap, item);
     111                 :            : 
     112                 :          0 : exit:
     113                 :          0 :     return return_value;
     114                 :            : }
     115                 :            : 
     116                 :            : PyDoc_STRVAR(_heapq_heappushpop__doc__,
     117                 :            : "heappushpop($module, heap, item, /)\n"
     118                 :            : "--\n"
     119                 :            : "\n"
     120                 :            : "Push item on the heap, then pop and return the smallest item from the heap.\n"
     121                 :            : "\n"
     122                 :            : "The combined action runs more efficiently than heappush() followed by\n"
     123                 :            : "a separate call to heappop().");
     124                 :            : 
     125                 :            : #define _HEAPQ_HEAPPUSHPOP_METHODDEF    \
     126                 :            :     {"heappushpop", _PyCFunction_CAST(_heapq_heappushpop), METH_FASTCALL, _heapq_heappushpop__doc__},
     127                 :            : 
     128                 :            : static PyObject *
     129                 :            : _heapq_heappushpop_impl(PyObject *module, PyObject *heap, PyObject *item);
     130                 :            : 
     131                 :            : static PyObject *
     132                 :          0 : _heapq_heappushpop(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     133                 :            : {
     134                 :          0 :     PyObject *return_value = NULL;
     135                 :            :     PyObject *heap;
     136                 :            :     PyObject *item;
     137                 :            : 
     138   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("heappushpop", nargs, 2, 2)) {
                   #  # ]
     139                 :          0 :         goto exit;
     140                 :            :     }
     141         [ #  # ]:          0 :     if (!PyList_Check(args[0])) {
     142                 :          0 :         _PyArg_BadArgument("heappushpop", "argument 1", "list", args[0]);
     143                 :          0 :         goto exit;
     144                 :            :     }
     145                 :          0 :     heap = args[0];
     146                 :          0 :     item = args[1];
     147                 :          0 :     return_value = _heapq_heappushpop_impl(module, heap, item);
     148                 :            : 
     149                 :          0 : exit:
     150                 :          0 :     return return_value;
     151                 :            : }
     152                 :            : 
     153                 :            : PyDoc_STRVAR(_heapq_heapify__doc__,
     154                 :            : "heapify($module, heap, /)\n"
     155                 :            : "--\n"
     156                 :            : "\n"
     157                 :            : "Transform list into a heap, in-place, in O(len(heap)) time.");
     158                 :            : 
     159                 :            : #define _HEAPQ_HEAPIFY_METHODDEF    \
     160                 :            :     {"heapify", (PyCFunction)_heapq_heapify, METH_O, _heapq_heapify__doc__},
     161                 :            : 
     162                 :            : static PyObject *
     163                 :            : _heapq_heapify_impl(PyObject *module, PyObject *heap);
     164                 :            : 
     165                 :            : static PyObject *
     166                 :          0 : _heapq_heapify(PyObject *module, PyObject *arg)
     167                 :            : {
     168                 :          0 :     PyObject *return_value = NULL;
     169                 :            :     PyObject *heap;
     170                 :            : 
     171         [ #  # ]:          0 :     if (!PyList_Check(arg)) {
     172                 :          0 :         _PyArg_BadArgument("heapify", "argument", "list", arg);
     173                 :          0 :         goto exit;
     174                 :            :     }
     175                 :          0 :     heap = arg;
     176                 :          0 :     return_value = _heapq_heapify_impl(module, heap);
     177                 :            : 
     178                 :          0 : exit:
     179                 :          0 :     return return_value;
     180                 :            : }
     181                 :            : 
     182                 :            : PyDoc_STRVAR(_heapq__heappop_max__doc__,
     183                 :            : "_heappop_max($module, heap, /)\n"
     184                 :            : "--\n"
     185                 :            : "\n"
     186                 :            : "Maxheap variant of heappop.");
     187                 :            : 
     188                 :            : #define _HEAPQ__HEAPPOP_MAX_METHODDEF    \
     189                 :            :     {"_heappop_max", (PyCFunction)_heapq__heappop_max, METH_O, _heapq__heappop_max__doc__},
     190                 :            : 
     191                 :            : static PyObject *
     192                 :            : _heapq__heappop_max_impl(PyObject *module, PyObject *heap);
     193                 :            : 
     194                 :            : static PyObject *
     195                 :          0 : _heapq__heappop_max(PyObject *module, PyObject *arg)
     196                 :            : {
     197                 :          0 :     PyObject *return_value = NULL;
     198                 :            :     PyObject *heap;
     199                 :            : 
     200         [ #  # ]:          0 :     if (!PyList_Check(arg)) {
     201                 :          0 :         _PyArg_BadArgument("_heappop_max", "argument", "list", arg);
     202                 :          0 :         goto exit;
     203                 :            :     }
     204                 :          0 :     heap = arg;
     205                 :          0 :     return_value = _heapq__heappop_max_impl(module, heap);
     206                 :            : 
     207                 :          0 : exit:
     208                 :          0 :     return return_value;
     209                 :            : }
     210                 :            : 
     211                 :            : PyDoc_STRVAR(_heapq__heapreplace_max__doc__,
     212                 :            : "_heapreplace_max($module, heap, item, /)\n"
     213                 :            : "--\n"
     214                 :            : "\n"
     215                 :            : "Maxheap variant of heapreplace.");
     216                 :            : 
     217                 :            : #define _HEAPQ__HEAPREPLACE_MAX_METHODDEF    \
     218                 :            :     {"_heapreplace_max", _PyCFunction_CAST(_heapq__heapreplace_max), METH_FASTCALL, _heapq__heapreplace_max__doc__},
     219                 :            : 
     220                 :            : static PyObject *
     221                 :            : _heapq__heapreplace_max_impl(PyObject *module, PyObject *heap,
     222                 :            :                              PyObject *item);
     223                 :            : 
     224                 :            : static PyObject *
     225                 :          0 : _heapq__heapreplace_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     226                 :            : {
     227                 :          0 :     PyObject *return_value = NULL;
     228                 :            :     PyObject *heap;
     229                 :            :     PyObject *item;
     230                 :            : 
     231   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("_heapreplace_max", nargs, 2, 2)) {
                   #  # ]
     232                 :          0 :         goto exit;
     233                 :            :     }
     234         [ #  # ]:          0 :     if (!PyList_Check(args[0])) {
     235                 :          0 :         _PyArg_BadArgument("_heapreplace_max", "argument 1", "list", args[0]);
     236                 :          0 :         goto exit;
     237                 :            :     }
     238                 :          0 :     heap = args[0];
     239                 :          0 :     item = args[1];
     240                 :          0 :     return_value = _heapq__heapreplace_max_impl(module, heap, item);
     241                 :            : 
     242                 :          0 : exit:
     243                 :          0 :     return return_value;
     244                 :            : }
     245                 :            : 
     246                 :            : PyDoc_STRVAR(_heapq__heapify_max__doc__,
     247                 :            : "_heapify_max($module, heap, /)\n"
     248                 :            : "--\n"
     249                 :            : "\n"
     250                 :            : "Maxheap variant of heapify.");
     251                 :            : 
     252                 :            : #define _HEAPQ__HEAPIFY_MAX_METHODDEF    \
     253                 :            :     {"_heapify_max", (PyCFunction)_heapq__heapify_max, METH_O, _heapq__heapify_max__doc__},
     254                 :            : 
     255                 :            : static PyObject *
     256                 :            : _heapq__heapify_max_impl(PyObject *module, PyObject *heap);
     257                 :            : 
     258                 :            : static PyObject *
     259                 :          0 : _heapq__heapify_max(PyObject *module, PyObject *arg)
     260                 :            : {
     261                 :          0 :     PyObject *return_value = NULL;
     262                 :            :     PyObject *heap;
     263                 :            : 
     264         [ #  # ]:          0 :     if (!PyList_Check(arg)) {
     265                 :          0 :         _PyArg_BadArgument("_heapify_max", "argument", "list", arg);
     266                 :          0 :         goto exit;
     267                 :            :     }
     268                 :          0 :     heap = arg;
     269                 :          0 :     return_value = _heapq__heapify_max_impl(module, heap);
     270                 :            : 
     271                 :          0 : exit:
     272                 :          0 :     return return_value;
     273                 :            : }
     274                 :            : /*[clinic end generated code: output=29e99a48c57f82bb input=a9049054013a1b77]*/

Generated by: LCOV version 1.14