fromOwnedSlice
Dequeue takes ownership of the passed in slice. The slice must have been
allocated with allocator.
De-initialize with deinit.
Function parameters
Parameters
Priority Dequeue for storing generic data.
Functions
- PriorityDequeue
- Priority Dequeue for storing generic data.
Source
Implementation
pub fn fromOwnedSlice(allocator: Allocator, items: []T, context: Context) Self {
var queue = Self{
.items = items,
.len = items.len,
.allocator = allocator,
.context = context,
};
if (queue.len <= 1) return queue;
const half = (queue.len >> 1) - 1;
var i: usize = 0;
while (i <= half) : (i += 1) {
const index = half - i;
queue.siftDown(index);
}
return queue;
}