-
Notifications
You must be signed in to change notification settings - Fork 0
/
_d_heap_queue.pxd
39 lines (33 loc) · 1.01 KB
/
_d_heap_queue.pxd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# cython: boundscheck=False
# cython: nonecheck=False
# Minimum spanning tree single linkage implementation for hdbscan
# Authors: Leland McInnes, Steve Astels
# License: 3-clause BSD
import cython
cimport cython
import numpy as np
cimport numpy as np
cpdef inline int compare_min_fn(list x, list y):
return int(x < y)
cpdef inline int compare_max_fn(list x, list y):
return int(x > y)
"""D-ary heap queue algorithm."""
cdef class HeapQueue(object):
cdef int n
cdef list heap
cdef object compare_fn
cdef list ids
cdef str type
cdef dict indexes
cdef int d
cdef int next_id
cdef int key_index
cdef int size(self)
cdef void set_key(self, int item_id, float new_key) except *
cdef void push(self, list item, int item_id=*)
cdef list pop(self)
cdef list replace(self, list item, int item_id=*)
cdef list push_and_pop(self, list item, int item_id=*)
cdef void heapify(self)
cdef void sift_down(self, int start_pos, int pos)
cdef void sift_up(self, int pos)