MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / put

Method put

graphs/multi_heuristic_astar.py:23–37  ·  view source on GitHub ↗
(self, item, priority)

Source from the content-addressed store, hash-verified

21 return len(self.elements) == 0
22
23 def put(self, item, priority):
24 if item not in self.set:
25 heapq.heappush(self.elements, (priority, item))
26 self.set.add(item)
27 else:
28 # update
29 # print("update", item)
30 temp = []
31 (pri, x) = heapq.heappop(self.elements)
32 while x != item:
33 temp.append((pri, x))
34 (pri, x) = heapq.heappop(self.elements)
35 temp.append((priority, item))
36 for pro, xxx in temp:
37 heapq.heappush(self.elements, (pro, xxx))
38
39 def remove_element(self, item):
40 if item in self.set:

Callers 4

bidirectional_dijFunction · 0.95
pass_and_relaxationFunction · 0.45
expand_stateFunction · 0.45
multi_a_starFunction · 0.45

Calls 2

addMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected