Skip to content

Commit

Permalink
Merge pull request #4331 from wilzbach/example_binaryheap
Browse files Browse the repository at this point in the history
add top-level example for binary heap
  • Loading branch information
burner committed Jun 1, 2016
2 parents e755d8b + 5f7a4ca commit 1e64085
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions std/container/binaryheap.d
Expand Up @@ -22,6 +22,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 1e64085

Please sign in to comment.