Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

make_heap()

Module:  Standard C++ Library   Library:  Algorithms


Function

Local Index

No Entries

Summary

Algorithm that creates a heap

Synopsis

#include <algorithm>

namespace std {
  template <class RandomAccessIterator>
  void
  make_heap(RandomAccessIterator start,
            RandomAccessIterator finish);

  template <class RandomAccessIterator, class Compare>
  void
  make_heap(RandomAccessIterator start,
            RandomAccessIterator finish, Compare comp);
}

Description

A heap is a particular organization of elements in a range between two random access iterators [a, b). Its two key properties are:

These properties make heaps useful as priority queues.

The heap algorithms use operator<() as the default comparison. In all of the algorithms, an alternate binary predicate function object can be specified.

The first version of the make_heap() algorithm arranges the elements in the range [start, finish) into a heap using operator<() to perform comparisons. The second version uses the comparison function object comp. Since the only requirements for a heap are the two listed above, make_heap() is not required to do anything within the range (start, finish - 1).

Complexity

This algorithm makes at most 3 * (finish - start) comparisons.

Example

See Also

pop_heap(), push_heap(), sort_heap()

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, 25.3.6.3



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.