Operation |
Output |
Priority Queue |
insertItem(5,A) |
- |
{ (5,A) } |
insertItem(9,C) |
- |
{ (5,A),
(9,C) } |
insertItem(3,B) |
- |
{ (3,B), (5,A), (9,C) } |
insertItem(7,D) |
- |
{ (3,B), (5,A), (7,D), (9,C) } |
minElement() |
B |
{ (3,B), (5,A), (7,D), (9,C) } |
minKey() |
3 |
{ (3,B), (5,A), (7,D), (9,C) } |
removeMin() |
- |
{ (5,A), (7,D), (9,C) } |
size() |
3 |
{ (5,A), (7,D), (9,C) } |
minElement() |
A |
{ (5,A), (7,D), (9,C) } |
removeMin() |
- |
{ (7,D), (9,C) } |
removeMin() |
- |
{ (9,C) } |
removeMin() |
- |
{ } |
removeMin() | ERROR |
{ } |
isEmpty() |
true |
{ } |
bool operator<(const Point& p1, const Point& p2)
{ if (p1.getX() == p2.getX()) return p1.getY() < p2.getY();
else return p1.getX() < p1.getX();
}
Assume that comp
is a compatison class object. comp(a,b)
returns integer i, such that