Commit ecfce5e
committed
feat: add PriorityQueueDemo showing custom ordering using Comparator in PriorityQueue
Implemented PriorityQueueDemo.java to demonstrate reverse (max-heap) ordering
via a user-defined Comparator. Highlights how PriorityQueue can be customized
beyond natural ordering, using compare() logic to prioritize higher values.
Includes peek(), poll(), and iteration to show heap behavior before and after deletion.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent 32c6411 commit ecfce5e
File tree
1 file changed
+1
-2
lines changed- Section 25 Collections Frameworks/Queue Interface/Priority Queue/src
1 file changed
+1
-2
lines changedLines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
| 35 | + | |
0 commit comments