Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BinaryHeap< Type, Compare > Class Template Reference

Detailed Description

template<typename Type, typename Compare = std::less<Type>>
class thrill::common::BinaryHeap< Type, Compare >

A simple binary heap priority queue, except that one can additionally find and delete arbitrary items in O(n).

Definition at line 31 of file binary_heap.hpp.

+ Inheritance diagram for BinaryHeap< Type, Compare >:

#include <binary_heap.hpp>

Public Types

using const_reference = const Type &
 
using Container = std::vector< Type >
 
using difference_type = typename Container::difference_type
 
using size_type = size_t
 
using value_type = Type
 

Public Member Functions

PQ Interface
 BinaryHeap (const Compare &cmp=Compare())
 
bool empty () const
 check if PQ is empty More...
 
size_type size () const
 return number of items in the PQ More...
 
const_reference top () const
 return reference to top item in PQ More...
 
template<typename... Args>
void emplace (Args &&...args)
 add an items in the PQ. More...
 
void pop ()
 remove the top item in the PQ More...
 
Additional Methods
Containercontainer ()
 direct access to heap container More...
 
template<typename Functor >
size_t erase (Functor &&f)
 

Static Public Member Functions

Free Binary Heap Methods
template<typename Iterator >
static void sift_up (Iterator first, Iterator last, const Compare &comp, difference_type len)
 
template<typename Iterator >
static void push_heap (Iterator first, Iterator last, const Compare &comp)
 
template<typename Iterator >
static void sift_down (Iterator first, Iterator, const Compare &comp, difference_type len, Iterator start)
 
template<typename Iterator >
static void pop_heap (Iterator first, Iterator last, const Compare &comp, difference_type len)
 
template<typename Iterator >
static void pop_heap (Iterator first, Iterator last, const Compare &comp)
 

Private Attributes

Container c_
 array holding binary heap More...
 
Compare cmp_
 compare More...
 

Member Typedef Documentation

using const_reference = const Type &

Definition at line 36 of file binary_heap.hpp.

using Container = std::vector<Type>

Definition at line 34 of file binary_heap.hpp.

using difference_type = typename Container::difference_type

Definition at line 38 of file binary_heap.hpp.

using size_type = size_t

Definition at line 37 of file binary_heap.hpp.

using value_type = Type

Definition at line 35 of file binary_heap.hpp.

Constructor & Destructor Documentation

BinaryHeap ( const Compare &  cmp = Compare())
inlineexplicit

Definition at line 43 of file binary_heap.hpp.

Member Function Documentation

Container& container ( )
inline

direct access to heap container

Definition at line 74 of file binary_heap.hpp.

Referenced by ProfileThread::~ProfileThread().

void emplace ( Args &&...  args)
inline

add an items in the PQ.

Definition at line 57 of file binary_heap.hpp.

Referenced by ProfileThread::Add(), and ProfileThread::Worker().

bool empty ( ) const
inline

check if PQ is empty

Definition at line 47 of file binary_heap.hpp.

Referenced by ProfileThread::Worker().

size_t erase ( Functor &&  f)
inline

iterate over all items, delete those for which f returns true. Takes time O(n). If you need to erase items frequently, use a different PQ.

Definition at line 79 of file binary_heap.hpp.

Referenced by ProfileThread::Remove().

void pop ( )
inline

remove the top item in the PQ

Definition at line 63 of file binary_heap.hpp.

Referenced by ProfileThread::Worker().

static void pop_heap ( Iterator  first,
Iterator  last,
const Compare &  comp,
difference_type  len 
)
inlinestatic

Definition at line 173 of file binary_heap.hpp.

Referenced by BinaryHeap< Timer >::pop(), and BinaryHeap< Timer >::pop_heap().

static void pop_heap ( Iterator  first,
Iterator  last,
const Compare &  comp 
)
inlinestatic

Definition at line 183 of file binary_heap.hpp.

static void push_heap ( Iterator  first,
Iterator  last,
const Compare &  comp 
)
inlinestatic

Definition at line 122 of file binary_heap.hpp.

Referenced by BinaryHeap< Timer >::emplace().

static void sift_down ( Iterator  first,
Iterator  ,
const Compare &  comp,
difference_type  len,
Iterator  start 
)
inlinestatic

Definition at line 127 of file binary_heap.hpp.

Referenced by BinaryHeap< Timer >::erase(), and BinaryHeap< Timer >::pop_heap().

static void sift_up ( Iterator  first,
Iterator  last,
const Compare &  comp,
difference_type  len 
)
inlinestatic

Definition at line 98 of file binary_heap.hpp.

Referenced by BinaryHeap< Timer >::push_heap().

size_type size ( ) const
inline

return number of items in the PQ

Definition at line 50 of file binary_heap.hpp.

const_reference top ( ) const
inline

return reference to top item in PQ

Definition at line 53 of file binary_heap.hpp.

Referenced by BinaryHeap< Timer >::sift_down(), and ProfileThread::Worker().

Member Data Documentation

Compare cmp_
private

The documentation for this class was generated from the following file: