MCPcopy
hub / github.com/networkx/networkx / push

Method push

networkx/utils/mapped_queue.py:174–187  ·  view source on GitHub ↗

Add an element to the queue.

(self, elt, priority=None)

Source from the content-addressed store, hash-verified

172 return len(self.heap)
173
174 def push(self, elt, priority=None):
175 """Add an element to the queue."""
176 if priority is not None:
177 elt = _HeapElement(priority, elt)
178 # If element is already in queue, do nothing
179 if elt in self.position:
180 return False
181 # Add element to heap and dict
182 pos = len(self.heap)
183 self.heap.append(elt)
184 self.position[elt] = pos
185 # Restore invariant by sifting down
186 self._siftdown(0, pos)
187 return True
188
189 def pop(self):
190 """Remove and return the smallest element in the queue."""

Callers 5

test_pushMethod · 0.95
test_push_duplicateMethod · 0.95
test_pushMethod · 0.95
test_push_duplicateMethod · 0.95

Calls 3

_siftdownMethod · 0.95
_HeapElementClass · 0.85
appendMethod · 0.80

Tested by 4

test_pushMethod · 0.76
test_push_duplicateMethod · 0.76
test_pushMethod · 0.76
test_push_duplicateMethod · 0.76