DoxigAlpha

fromOwnedSlice

PriorityQueue takes ownership of the passed in slice. The slice must have been allocated with allocator. Deinitialize with deinit.

Function parameters

Parameters

#
items:[]T
context:Context

Priority queue for storing generic data.

Functions

#
PriorityQueue
Priority queue for storing generic data.

Source

Implementation

#
pub fn fromOwnedSlice(allocator: Allocator, items: []T, context: Context) Self {
    var self = Self{
        .items = items,
        .cap = items.len,
        .allocator = allocator,
        .context = context,
    };

    var i = self.items.len >> 1;
    while (i > 0) {
        i -= 1;
        self.siftDown(i);
    }
    return self;
}