3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Data Structures</title>
5 <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8 <link rel="up" href="../heap.html" title="Chapter 13. Boost.Heap">
9 <link rel="prev" href="concepts.html" title="Concepts & Interface">
10 <link rel="next" href="reference.html" title="Reference">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
15 <td align="center"><a href="../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="concepts.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../heap.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="heap.data_structures"></a><a class="link" href="data_structures.html" title="Data Structures">Data Structures</a>
28 </h2></div></div></div>
29 <div class="toc"><dl class="toc"><dt><span class="section"><a href="data_structures.html#heap.data_structures.data_structure_configuration">Data
30 Structure Configuration</a></span></dt></dl></div>
32 <code class="literal">boost.heap</code> provides the following data structures:
34 <div class="variablelist">
35 <p class="title"><b></b></p>
36 <dl class="variablelist">
37 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/priority_queue.html" title="Class template priority_queue">boost::heap::priority_queue</a></code></span></dt>
39 The <code class="computeroutput"><a class="link" href="../boost/heap/priority_queue.html" title="Class template priority_queue">priority_queue</a></code>
40 class is a wrapper to the stl heap functions. It implements a heap as
41 container adaptor ontop of a <code class="literal">std::vector</code> and is immutable.
43 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/d_ary_heap.html" title="Class template d_ary_heap">boost::heap::d_ary_heap</a></code></span></dt>
46 <a href="http://en.wikipedia.org/wiki/D-ary_heap" target="_top">D-ary heaps</a>
47 are a generalization of binary heap with each non-leaf node having N
48 children. For a low arity, the height of the heap is larger, but the
49 number of comparisons to find the largest child node is bigger. D-ary
50 heaps are implemented as container adaptors based on a <code class="literal">std::vector</code>.
53 The data structure can be configured as mutable. This is achieved by
54 storing the values inside a std::list.
57 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/binomial_heap.html" title="Class template binomial_heap">boost::heap::binomial_heap</a></code></span></dt>
59 <a href="http://en.wikipedia.org/wiki/Binomial_heap" target="_top">Binomial heaps</a>
60 are node-base heaps, that are implemented as a set of binomial trees
61 of piecewise different order. The most important heap operations have
62 a worst-case complexity of O(log n). In contrast to d-ary heaps, binomial
63 heaps can also be merged in O(log n).
65 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/fibonacci_heap.html" title="Class template fibonacci_heap">boost::heap::fibonacci_heap</a></code></span></dt>
67 <a href="http://en.wikipedia.org/wiki/Fibonacci_heap" target="_top">Fibonacci heaps</a>
68 are node-base heaps, that are implemented as a forest of heap-ordered
69 trees. They provide better amortized performance than binomial heaps.
70 Except <code class="literal">pop()</code> and <code class="literal">erase()</code>, the most
71 important heap operations have constant amortized complexity.
73 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/pairing_heap.html" title="Class template pairing_heap">boost::heap::pairing_heap</a></code></span></dt>
76 <a href="http://en.wikipedia.org/wiki/Pairing_heap" target="_top">Pairing heaps</a>
77 are self-adjusting node-based heaps. Although design and implementation
78 are rather simple, the complexity analysis is yet unsolved. For details,
82 Pettie, Seth (2005), "Towards a final analysis of pairing heaps",
83 Proc. 46th Annual IEEE Symposium on Foundations of Computer Science,
87 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/skew_heap.html" title="Class template skew_heap">boost::heap::skew_heap</a></code></span></dt>
89 <a href="http://en.wikipedia.org/wiki/Skew_heap" target="_top">Skew heaps</a>
90 are self-adjusting node-based heaps. Although there are no constraints
91 for the tree structure, all heap operations can be performed in O(log
97 <a name="heap.data_structures.t0"></a><p class="title"><b>Table 13.1. Comparison of amortized complexity</b></p>
98 <div class="table-contents"><table class="table" summary="Comparison of amortized complexity">
115 <code class="literal">top()</code>
120 <code class="literal">push()</code>
125 <code class="literal">pop()</code>
130 <code class="literal">update()</code>
135 <code class="literal">increase()</code>
140 <code class="literal">decrease()</code>
145 <code class="literal">erase()</code>
150 <code class="literal">merge_and_clear()</code>
158 <code class="computeroutput"><a class="link" href="../boost/heap/priority_queue.html" title="Class template priority_queue">boost::heap::priority_queue</a></code>
163 <code class="literal">O(1)</code>
205 <code class="computeroutput"><a class="link" href="../boost/heap/d_ary_heap.html" title="Class template d_ary_heap">boost::heap::d_ary_heap</a></code>
210 <code class="literal">O(1)</code>
252 <code class="computeroutput"><a class="link" href="../boost/heap/binomial_heap.html" title="Class template binomial_heap">boost::heap::binomial_heap</a></code>
257 <code class="literal">O(1)</code>
299 <code class="computeroutput"><a class="link" href="../boost/heap/fibonacci_heap.html" title="Class template fibonacci_heap">boost::heap::fibonacci_heap</a></code>
304 <code class="literal">O(1)</code>
319 O(log(N)) <a href="#ftn.heap.data_structures.f0" class="footnote" name="heap.data_structures.f0"><sup class="footnote">[a]</sup></a>
346 <code class="computeroutput"><a class="link" href="../boost/heap/pairing_heap.html" title="Class template pairing_heap">boost::heap::pairing_heap</a></code>
351 <code class="literal">O(1)</code>
393 <code class="computeroutput"><a class="link" href="../boost/heap/skew_heap.html" title="Class template skew_heap">boost::heap::skew_heap</a></code>
398 <code class="literal">O(1)</code>
438 <tbody class="footnotes"><tr><td colspan="9"><div id="ftn.heap.data_structures.f0" class="footnote"><p><a href="#heap.data_structures.f0" class="para"><sup class="para">[a] </sup></a>
439 The fibonacci a <code class="literal">update_lazy()</code> method, which
440 has O(log(N)) amortized complexity as well, but does not try to
441 consolidate the internal forest
442 </p></div></td></tr></tbody>
445 <br class="table-break"><div class="section">
446 <div class="titlepage"><div><div><h3 class="title">
447 <a name="heap.data_structures.data_structure_configuration"></a><a class="link" href="data_structures.html#heap.data_structures.data_structure_configuration" title="Data Structure Configuration">Data
448 Structure Configuration</a>
449 </h3></div></div></div>
451 The data structures can be configured with <a href="../../../libs/parameter/doc/html/index.html" target="_top">Boost.Parameter</a>-style
454 <div class="variablelist">
455 <p class="title"><b></b></p>
456 <dl class="variablelist">
457 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/compare.html" title="Struct template compare">boost::heap::compare</a></code></span></dt>
459 Predicate for defining the heap order, optional (defaults to <code class="literal">boost::heap::compare<std::less<T>
462 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/allocator.html" title="Struct template allocator">boost::heap::allocator</a></code></span></dt>
464 Allocator for internal memory management, optional (defaults to <code class="literal">boost::heap::allocator<std::allocator<T>
467 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/stable.html" title="Struct template stable">boost::heap::stable</a></code></span></dt>
469 Configures the heap to use a <a class="link" href="concepts.html#heap.concepts.stability" title="Stability">stable
470 heap order</a>, optional (defaults to <code class="literal">boost::heap::stable<false></code>).
472 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/mutable_.html" title="Struct template mutable_">boost::heap::mutable_</a></code></span></dt>
474 Configures the heap to be mutable. <code class="computeroutput"><a class="link" href="../boost/heap/d_ary_heap.html" title="Class template d_ary_heap">boost::heap::d_ary_heap</a></code>
475 and <code class="computeroutput"><a class="link" href="../boost/heap/skew_heap.html" title="Class template skew_heap">boost::heap::skew_heap</a></code>
476 have to be configured with this policy to enable the <a class="link" href="concepts.html#heap.concepts.mutability" title="Mutability">mutability
479 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/stability_counter_type.html" title="Struct template stability_counter_type">boost::heap::stability_counter_type</a></code></span></dt>
481 Configures the integer type used for the stability counter, optional
482 (defaults to <code class="literal">boost::heap::stability_counter_type<boost::uintmax_t></code>).
483 For more details, consult the <a class="link" href="concepts.html#heap.concepts.stability" title="Stability">Stability</a>
486 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/constant_time_size.html" title="Struct template constant_time_size">boost::heap::constant_time_size</a></code></span></dt>
488 Specifies, whether <code class="literal">size()</code> should have linear or
489 constant complexity. This argument is only available for node-based
490 heap data structures and if available, it is optional (defaults to
491 <code class="literal">boost::heap::constant_time_size<true></code>)
493 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/arity.html" title="Struct template arity">boost::heap::arity</a></code></span></dt>
495 Specifies the arity of a d-ary heap. For details, please consult the
496 class reference of <code class="computeroutput"><a class="link" href="../boost/heap/d_ary_heap.html" title="Class template d_ary_heap">boost::heap::d_ary_heap</a></code>
498 <dt><span class="term"><code class="computeroutput"><a class="link" href="../boost/heap/store_parent_pointer.html" title="Struct template store_parent_pointer">boost::heap::store_parent_pointer</a></code></span></dt>
500 Store the parent pointer in the heap nodes. This policy is only available
501 in the <code class="computeroutput"><a class="link" href="../boost/heap/skew_heap.html" title="Class template skew_heap">boost::heap::skew_heap</a></code>.
507 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
508 <td align="left"></td>
509 <td align="right"><div class="copyright-footer">Copyright © 2010, 2011 Tim Blechmann<p>
510 Distributed under the Boost Software License, Version 1.0. (See accompanying
511 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
516 <div class="spirit-nav">
517 <a accesskey="p" href="concepts.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../heap.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>