core/container/priority_queue
container_priority_queue
Types
1Priority_Queue
Priority_Queue :: struct {}SourcePriority Queue.
Important: It needs to be initialized with less and swap procedures, see init and init_from_dynamic_array. See doc.odin for an example.
Constants
1Procedures
17_shift_down
_shift_down :: proc(pq: ^Q, i0: int, n: int) -> (bool)Source_shift_up
_shift_up :: proc(pq: ^Q, j: int)Sourcecap
cap :: proc(pq: Q) -> (int)Sourceclear
clear :: proc(pq: ^Q)Sourcedefault_swap_proc
default_swap_proc :: proc(T: typeid) -> (proc(q: []T, i: int, j: int))Sourcedestroy
destroy :: proc(pq: ^Q)Sourcefix
fix :: proc(pq: ^Q, i: int)SourceNOTE(bill): When an element at index 'i' has changed its value, this will fix the the heap ordering. This is using a basic "heapsort" with shift up and a shift down parts.
init
init :: proc(pq: ^Q, less: proc(a: T, b: T) -> (bool), swap: proc(q: []T, i: int, j: int), capacity = DEFAULT_CAPACITY, allocator: mem.Allocator = context.allocator) -> (err: runtime.Allocator_Error)Sourceinit_from_dynamic_array
init_from_dynamic_array :: proc(pq: ^Q, queue: [dynamic]T, less: proc(a: T, b: T) -> (bool), swap: proc(q: []T, i: int, j: int))Sourcelen
len :: proc(pq: Q) -> (int)Sourcepeek
peek :: proc(pq: Q, loc = #caller_location) -> (res: T)Sourcepeek_safe
peek_safe :: proc(pq: Q, loc = #caller_location) -> (res: T, ok: bool)Sourcepop
pop :: proc(pq: ^Q, loc = #caller_location) -> (value: T)Sourcepop_safe
pop_safe :: proc(pq: ^Q, loc = #caller_location) -> (value: T, ok: bool)Sourcepush
push :: proc(pq: ^Q, value: T) -> (err: runtime.Allocator_Error)Sourceremove
remove :: proc(pq: ^Q, i: int) -> (value: T, ok: bool)Sourcereserve
reserve :: proc(pq: ^Q, capacity: int) -> (err: runtime.Allocator_Error)Source