MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / pop

Method pop

easygraph/utils/mapped_queue.py:85–102  ·  view source on GitHub ↗

Remove and return the smallest element in the queue.

(self)

Source from the content-addressed store, hash-verified

83 return True
84
85 def pop(self):
86 """Remove and return the smallest element in the queue."""
87 # Remove smallest element
88 elt = self.h[0]
89 del self.d[elt]
90 # If elt is last item, remove and return
91 if len(self.h) == 1:
92 self.h.pop()
93 return elt
94 # Replace root with last element
95 last = self.h.pop()
96 self.h[0] = last
97 self.d[last] = 0
98 # Restore invariant by sifting up, then down
99 pos = self._siftup(0)
100 self._siftdown(pos)
101 # Return smallest element
102 return elt
103
104 def update(self, elt, new):
105 """Replace an element in the queue with a new one."""

Callers 15

prim_mst_edgesFunction · 0.80
create_alias_tableFunction · 0.80
alias_setupFunction · 0.80
removeMethod · 0.80
remove_hyperedgesMethod · 0.80
remove_groupMethod · 0.80
_clear_cacheMethod · 0.80
remove_hyperedgesMethod · 0.80

Calls 2

_siftupMethod · 0.95
_siftdownMethod · 0.95

Tested by

no test coverage detected