MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / put

Method put

Graphs/multi_hueristic_astar.py:25–39  ·  view source on GitHub ↗
(self, item, priority)

Source from the content-addressed store, hash-verified

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

Callers 2

expand_stateFunction · 0.45
multi_a_starFunction · 0.45

Calls 1

addMethod · 0.80

Tested by

no test coverage detected