|
Space-efficient geometric algorithms and data structuresBy Ilya Katz and Hervé Brönnimann |
Internally, the nodes are organized by levels, starting with node 0 at level 0. Level k has k+1 nodes, numbered consecutively. Therefore, the first node on the kth level is numbered
. The left parent of the ith node on level k is numbered
and the right is
. A node at level k does not have a left parent if it is equal to
. A node at level k does not have a right parent if it is equal to
. The level k of a node i can be computed by solving
, or
, but it is much faster to be computed by binary search.
The following collection of functions provides a space efficient implementation of the beap.
Definition in file beap.hpp.
Go to the source code of this file.
Namespaces | |
| namespace | beap_detail |
Functions | |
| unsigned short | beap_detail::my_sqrt (unsigned long a) |
| template<class Distance> | |
| int | beap_detail::level (Distance p) |
| template<class RandomAccessIterator> | |
| bool | is_beap (RandomAccessIterator first, RandomAccessIterator last) |
Returns true if [first, last) is a valid beap data structure. | |
| template<class RandomAccessIterator, class StrictWeakOrdering> | |
| bool | is_beap (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp) |
Returns true if [first, last) is a valid beap data structure. | |
| template<class RandomAccessIterator> | |
| void | make_beap (RandomAccessIterator first, RandomAccessIterator last) |
make_beap turns [first, last) into a beap. This algorithm is provided for completeness, although std::sort(first,last) achieves the same effect and has a better complexity. | |
| template<class RandomAccessIterator, class StrictWeakOrdering> | |
| void | make_beap (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp) |
make_beap turns [first, last) into a beap. This algorithm is provided for completeness, although std::sort(first,last) achieves the same effect and has a better complexity. | |
| template<class RandomAccessIterator> | |
| RandomAccessIterator | min_beap (RandomAccessIterator first, RandomAccessIterator last) |
| Returns the iterator to the smallest element in the beap. | |
| template<class RandomAccessIterator, class StrictWeakOrdering> | |
| RandomAccessIterator | min_beap (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp) |
| Returns the iterator to the smallest element in the beap. | |
| template<class RandomAccessIterator> | |
| RandomAccessIterator | max_beap (RandomAccessIterator first, RandomAccessIterator last) |
| Returns the iterator to the largest element in the beap. | |
| template<class RandomAccessIterator, class StrictWeakOrdering> | |
| RandomAccessIterator | max_beap (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp) |
| Returns the iterator to the largest element in the beap. | |
| template<class RandomAccessIterator> | |
| void | insert_beap (RandomAccessIterator first, RandomAccessIterator last) |
Adds an element to the beap and preserves beap's property. The element to be added to the beap is at iterator (last-1) . | |
| template<class RandomAccessIterator, class StrictWeakOrdering> | |
| void | insert_beap (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp) |
Adds an element to the beap and preserves beap's property. The element to be added to the beap is at iterator (last-1) . | |
| template<class T, class RandomAccessIterator> | |
| RandomAccessIterator | find_beap (RandomAccessIterator first, RandomAccessIterator last, T x) |
| Returns iterator to the location of the desired element. If there is more than one appearance of the element in the beap, the returned location is not necessarily the first location in the corresponding array. | |
| template<class T, class RandomAccessIterator, class StrictWeakOrdering> | |
| RandomAccessIterator | find_beap (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp, T x) |
| Returns iterator to the location of the desired element. If there is more than one appearance of the element in the beap, the returned location is not necessarily the first location in the corresponding array. | |
| template<class RandomAccessIterator> | |
| void | sort_beap (RandomAccessIterator first, RandomAccessIterator last) |
Turns a beap [first, last) into a sorted range. | |
| template<class RandomAccessIterator, class StrictWeakOrdering> | |
| void | sort_beap (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp) |
Turns a beap [first, last) into a sorted range. | |
| template<class RandomAccessIterator> | |
| void | remove_beap (RandomAccessIterator first, RandomAccessIterator pos, RandomAccessIterator last) |
Removes element at position pos from the beap and adjusts the beap. | |
| template<class RandomAccessIterator, class StrictWeakOrdering> | |
| void | remove_beap (RandomAccessIterator first, RandomAccessIterator pos, RandomAccessIterator last, StrictWeakOrdering comp) |
Removes element at position pos from the beap and adjusts the beap. | |
|
||||||||||||||||||||||||
|
Returns iterator to the location of the desired element. If there is more than one appearance of the element in the beap, the returned location is not necessarily the first location in the corresponding array.
|
|
||||||||||||||||||||
|
Returns iterator to the location of the desired element. If there is more than one appearance of the element in the beap, the returned location is not necessarily the first location in the corresponding array.
|
|
||||||||||||||||||||
|
Adds an element to the beap and preserves beap's property. The element to be added to the beap is at iterator
|
|
||||||||||||||||
|
Adds an element to the beap and preserves beap's property. The element to be added to the beap is at iterator
|
|
||||||||||||||||||||
|
Returns true if [
|
|
||||||||||||||||
|
Returns true if [
|
|
||||||||||||||||||||
|
make_beap turns [
|
|
||||||||||||||||
|
make_beap turns [
|
|
||||||||||||||||||||
|
Returns the iterator to the largest element in the beap.
|
|
||||||||||||||||
|
Returns the iterator to the largest element in the beap.
|
|
||||||||||||||||||||
|
Returns the iterator to the smallest element in the beap.
|
|
||||||||||||||||
|
Returns the iterator to the smallest element in the beap.
|
|
||||||||||||||||||||||||
|
Removes element at position
|
|
||||||||||||||||||||
|
Removes element at position
|
|
||||||||||||||||||||
|
Turns a beap [
|
|
||||||||||||||||
|
Turns a beap [
|
Code Documentation generated Using Doxygen
Copyright © Ilya Katz and Herve Bronnimann, 2005.