Skip to content

Instantly share code, notes, and snippets.

@bolonge
Created July 22, 2022 07:26
힙으로 구현한 우선순위 큐
class Heap():
...
class PQueue():
def __init__(self, pc):
self.heap = Heap(pc)
def isEmpty(self) -> bool:
return self.heap.HIsEmpty()
def enqueue(self, data: HData) -> None:
return self.heap.HInsert(data)
def dequeue(self) -> HData:
return self.heap.HDelete()
def dataPriorityComp(ch1: str, ch2: str):
return ord(ch2) - ord(ch1)
pq = PQueue(dataPriorityComp)
pq.enqueue(HData("A"))
pq.enqueue(HData("B"))
pq.enqueue(HData("C"))
while pq.isEmpty() != True:
print(pq.dequeue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment