Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

fromOwnedSlice

Public Function
std.priority_dequeue.PriorityDequeue.fromOwnedSlice
pub fn fromOwnedSlice(items: []T, context: Context) Self

Dequeue takes ownership of the passed in slice. The slice must be de-initialize with deinit.

Params

  • items: []T
  • context: Context

File

priority_dequeue.zig:330
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
        pub fn fromOwnedSlice(items: []T, context: Context) Self {
            var queue = Self{
                .items = items,
                .len = items.len,
                .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;
        }