powered by
The PriorityQueue class creates a priority queue (a.k.a heap).
PriorityQueue
An object of class R6ClassGenerator of length 24.
R6ClassGenerator
PriorityQueue$new() PriorityQueue$push(item, priority = 0) PriorityQueue$pop() PriorityQueue$size() PriorityQueue$as_list()
item: any R object
item
priority: non-negative interger, item with larger priority pops first
priority
# NOT RUN { q <- PriorityQueue$new() q$push("not_urgent") q$push("urgent", priority = 2) q$push("not_as_urgent", priority = 1) q$pop() # urgent q$pop() # not_as_urgent q$pop() # not_urgent # }
Run the code above in your browser using DataLab