Home | Libraries | People | FAQ | More |
boost::heap::fibonacci_heap — fibonacci heap
// In header: <boost/heap/fibonacci_heap.hpp> template<typename T, class... Options> class fibonacci_heap { public: // types typedef T value_type; typedef implementation_defined::size_type size_type; typedef implementation_defined::difference_type difference_type; typedef implementation_defined::value_compare value_compare; typedef implementation_defined::allocator_type allocator_type; typedef implementation_defined::reference reference; typedef implementation_defined::const_reference const_reference; typedef implementation_defined::pointer pointer; typedef implementation_defined::const_pointer const_pointer; typedef implementation_defined::iterator iterator; typedef implementation_defined::const_iterator const_iterator; typedef implementation_defined::ordered_iterator ordered_iterator; typedef implementation_defined::handle_type handle_type; // construct/copy/destruct explicit fibonacci_heap(value_compare const & = value_compare()); fibonacci_heap(fibonacci_heap const &); fibonacci_heap(fibonacci_heap &&); fibonacci_heap& operator=(fibonacci_heap &&); fibonacci_heap& operator=(fibonacci_heap const &); ~fibonacci_heap(void); // public member functions bool empty(void) const; size_type size(void) const; size_type max_size(void) const; void clear(void); allocator_type get_allocator(void) const; void swap(fibonacci_heap &); value_type const & top(void) const; handle_type push(value_type const &); template<class... Args> handle_type emplace(Args &&...); void pop(void); void update(handle_type, const_reference); void update_lazy(handle_type, const_reference); void update(handle_type); void update_lazy(handle_type); void increase(handle_type, const_reference); void increase(handle_type); void decrease(handle_type, const_reference); void decrease(handle_type); void erase(handle_type const &); iterator begin(void) const; iterator end(void) const; ordered_iterator ordered_begin(void) const; ordered_iterator ordered_end(void) const; void merge(fibonacci_heap &); value_compare const & value_comp(void) const; template<typename HeapType> bool operator<(HeapType const &) const; template<typename HeapType> bool operator>(HeapType const &) const; template<typename HeapType> bool operator>=(HeapType const &) const; template<typename HeapType> bool operator<=(HeapType const &) const; template<typename HeapType> bool operator==(HeapType const &) const; template<typename HeapType> bool operator!=(HeapType const &) const; // public static functions static handle_type s_handle_from_iterator(iterator const &); // public data members static const bool constant_time_size; static const bool has_ordered_iterators; static const bool is_mergable; static const bool is_stable; static const bool has_reserve; };
The template parameter T is the type to be managed by the container. The user can specify additional options and if no options are provided default options are used.
The container supports the following options:
boost::heap::stable<>
, defaults to stable<false>
boost::heap::compare<>
, defaults to compare<std::less<T>
>
boost::heap::allocator<>
, defaults to allocator<std::allocator<T>
>
boost::heap::constant_time_size<>
, defaults to constant_time_size<true>
boost::heap::stability_counter_type<>
, defaults to stability_counter_type<boost::uintmax_t>
fibonacci_heap
public
construct/copy/destructexplicit fibonacci_heap(value_compare const & cmp = value_compare());
Effects: constructs an empty priority queue.
Complexity: Constant.
fibonacci_heap(fibonacci_heap const & rhs);
Effects: copy-constructs priority queue from rhs.
Complexity: Linear.
fibonacci_heap(fibonacci_heap && rhs);
Effects: C++11-style move constructor.
Complexity: Constant.
Note: Only available, if BOOST_HAS_RVALUE_REFS is defined
fibonacci_heap& operator=(fibonacci_heap && rhs);
Effects: C++11-style move assignment.
Complexity: Constant.
Note: Only available, if BOOST_HAS_RVALUE_REFS is defined
fibonacci_heap& operator=(fibonacci_heap const & rhs);
Effects: Assigns priority queue from rhs.
Complexity: Linear.
~fibonacci_heap(void);
fibonacci_heap
public member functionsbool empty(void) const;
Effects: Returns true, if the priority queue contains no elements.
Complexity: Constant.
size_type size(void) const;
Effects: Returns the number of elements contained in the priority queue.
Complexity: Constant.
size_type max_size(void) const;
Effects: Returns the maximum number of elements the priority queue can contain.
Complexity: Constant.
void clear(void);
Effects: Removes all elements from the priority queue.
Complexity: Linear.
allocator_type get_allocator(void) const;
Effects: Returns allocator.
Complexity: Constant.
void swap(fibonacci_heap & rhs);
Effects: Swaps two priority queues.
Complexity: Constant.
value_type const & top(void) const;
Effects: Returns a const_reference to the maximum element.
Complexity: Constant.
handle_type push(value_type const & v);
Effects: Adds a new element to the priority queue. Returns handle to element
Complexity: Constant.
Note: Does not invalidate iterators.
template<class... Args> handle_type emplace(Args &&... args);
Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns handle to element.
Complexity: Constant.
Note: Does not invalidate iterators.
void pop(void);
Effects: Removes the top element from the priority queue.
Complexity: Logarithmic (amortized). Linear (worst case).
void update(handle_type handle, const_reference v);
Effects: Assigns v
to the element handled by handle
& updates the priority queue.
Complexity: Logarithmic if current value < v, Constant otherwise.
void update_lazy(handle_type handle, const_reference v);
Effects: Assigns v
to the element handled by handle
& updates the priority queue.
Complexity: Logarithmic if current value < v, Constant otherwise.
Rationale: The lazy update function is a modification of the traditional update, that just invalidates the iterator the the object referred to by the handle.
void update(handle_type handle);
Effects: Updates the heap after the element handled by handle
has been changed.
Complexity: Logarithmic.
Note: If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
void update_lazy(handle_type handle);
Effects: Assigns v
to the element handled by handle
& updates the priority queue.
Complexity: Logarithmic if current value < v, Constant otherwise.
(handle_type handle)
Rationale: The lazy update function is a modification of the traditional update, that just invalidates the iterator the the object referred to by the handle.
void increase(handle_type handle, const_reference v);
Effects: Assigns v
to the element handled by handle
& updates the priority queue.
Complexity: Constant.
Note: The new value is expected to be greater than the current one
void increase(handle_type handle);
Effects: Updates the heap after the element handled by handle
has been changed.
Complexity: Constant.
Note: If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
void decrease(handle_type handle, const_reference v);
Effects: Assigns v
to the element handled by handle
& updates the priority queue.
Complexity: Logarithmic.
Note: The new value is expected to be less than the current one
void decrease(handle_type handle);
Effects: Updates the heap after the element handled by handle
has been changed.
Complexity: Logarithmic.
Note: The new value is expected to be less than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
void erase(handle_type const & handle);
Effects: Removes the element handled by handle
from the priority_queue
.
Complexity: Logarithmic.
iterator begin(void) const;
Effects: Returns an iterator to the first element contained in the priority queue.
Complexity: Constant.
iterator end(void) const;
Effects: Returns an iterator to the end of the priority queue.
Complexity: Constant.
ordered_iterator ordered_begin(void) const;
Effects: Returns an ordered iterator to the first element contained in the priority queue.
Note: Ordered iterators traverse the priority queue in heap order.
ordered_iterator ordered_end(void) const;
Effects: Returns an ordered iterator to the first element contained in the priority queue.
Note: Ordered iterators traverse the priority queue in heap order.
void merge(fibonacci_heap & rhs);
Effects: Merge with priority queue rhs.
Complexity: Constant.
value_compare const & value_comp(void) const;
Effect: Returns the value_compare object used by the priority queue
template<typename HeapType> bool operator<(HeapType const & rhs) const;
Returns: Element-wise comparison of heap data structures
Requirement: the value_compare
object of both heaps must match.
template<typename HeapType> bool operator>(HeapType const & rhs) const;
Returns: Element-wise comparison of heap data structures
Requirement: the value_compare
object of both heaps must match.
template<typename HeapType> bool operator>=(HeapType const & rhs) const;
Returns: Element-wise comparison of heap data structures
Requirement: the value_compare
object of both heaps must match.
template<typename HeapType> bool operator<=(HeapType const & rhs) const;
Returns: Element-wise comparison of heap data structures
Requirement: the value_compare
object of both heaps must match.
template<typename HeapType> bool operator==(HeapType const & rhs) const;
Equivalent comparison Returns: True, if both heap data structures are equivalent.
Requirement: the value_compare
object of both heaps must match.
template<typename HeapType> bool operator!=(HeapType const & rhs) const;
Equivalent comparison Returns: True, if both heap data structures are not equivalent.
Requirement: the value_compare
object of both heaps must match.