Skip to content

Commit

Permalink
add top-level example for binary heap
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed May 25, 2016
1 parent 778593d commit 5f7a4ca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions std/container/binaryheap.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ import std.traits;

public import std.container.util;

///
unittest
{
import std.algorithm.comparison : equal;
import std.range : take;
auto maxHeap = heapify([4, 7, 3, 1, 5]);
assert(maxHeap.take(3).equal([7, 5, 4]));

auto minHeap = heapify!"a > b"([4, 7, 3, 1, 5]);
assert(minHeap.take(3).equal([1, 3, 4]));
}

// BinaryHeap
/**
Implements a $(WEB en.wikipedia.org/wiki/Binary_heap, binary heap)
Expand Down

0 comments on commit 5f7a4ca

Please sign in to comment.