This module provides a (aka priority queue) adaptor that makes a binary heap out of any user-provided random-access range.

Current implementation is suitable for Mir/BetterC concepts. This module is a submodule of .

Copyright

2010- Andrei Alexandrescu. All rights reserved by the respective holders.

License

Distributed under the Boost Software License, Version 1.0.

Authors

(original Phobos code), Ilya Yaroshenko (Mir & BetterC rework).

Example

import mir.algorithm.iteration : equal;
import std.range : takeExactly;
static a = [4, 7, 3, 1, 5], b = [7, 5, 4];
auto maxHeap = a.heapify;
assert((&maxHeap).takeExactly(3).equal(b));

static c = [4, 7, 3, 1, 5], d = [1, 3, 4];
auto minHeap = c.heapify!"a > b";
assert((&minHeap).takeExactly(3).equal(d));

Functions

heapify

Structs

BinaryHeap

Templates

HeapOps