Skip to main content

PriorityQueue.update

Check if an item is present in the heap

Usage

update(item:Any, new_item:Any)

Parameters:
      item : element
            Item to be replaced
      new_item : element
            The new item

Example

from jellybeans.structures import PriorityQueue as PQpq = PQ(comparator=lambda x,y: x<=y) # Min heappq.insert(10)pq.insert(5)pq.insert(15)pq.insert(25)print(pq) # [None, 5, 10, 15, 25]pq.update(15, 35)print(pq.search(15)) # Falseprint(pq) # [None, 5, 10, 35, 25]