Skip to content

Sunkist18/Updatable-Priority-Queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Updatable-Priority-Queue

힙 기반의 업데이트 가능한 우선순위 큐의 구현입니다.
내부에 기존 위치(인덱스)를 추적할 수 있는 배열이 존재합니다.

Usage

  • insert(T value)
  • update(int index, T value)
  • extractMin()
  • print()

Example

int main() {
  std::vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  UpdatablePriorityQueue<int> upq(v);
  upq.print();
  upq.update(3, 0);
  upq.print();
  upq.update(3, 10);
  upq.print();
  for (int i = 0; i < 9; i++) {
    std::cout << upq.extractMin() << " ";
  }
  return 0;
}
1 2 3 4 5 6 7 8 9
0 1 3 2 5 6 7 8 9
0 1 3 8 5 6 7 10 9
0 1 3 5 6 7 8 9 10

About

implements a heap-based updatable priority queue.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages