the ids \( [ 0 , n ) \) by a key, the least on top, with the least of their bounds
More...
#include <ADS/priority/IndexedHeapPair.h>
|
| using | Key = K |
| | the type of the keys of selection
|
| using | Bound = Bd |
| | the type of the bounds
|
|
| | IndexedHeapPair (int n=0) |
| | the empty queue of the ids \( [ 0 , n ) \)
|
| void | reset (int n) |
| | the empty queue of the ids \( [ 0 , n ) \), the room kept
|
| int | ids (void) const |
| | the number of ids, \( n \)
|
| bool | empty (void) const |
| | whether the queue has no id
|
| std::size_t | size (void) const |
| | the number of ids in the queue, \( s \)
|
| bool | contains (int id) const |
| | whether the id is in the queue
|
| const K & | key (int id) const |
| | the key of an id in the queue
|
| const Bd & | bound (int id) const |
| | the bound of an id in the queue
|
| void | push (int id, const K &k, const Bd &b) |
| | inserts the id with the key \( k \) and the bound \( b \), in \( O( \log_D s ) \) time
|
| void | update (int id, const K &k, const Bd &b) |
| | sets the key of the id to \( k \) and its bound to \( b \), each heap moving the id up or down, in \( O( D \log_D s ) \) time
|
| void | erase (int id) |
| | removes the id from the queue, in \( O( D \log_D s ) \) time
|
| int | top (void) const |
| | the id of least key
|
| const K & | topKey (void) const |
| | the least key, that of top()
|
| const Bd & | minBound (void) const |
| | the least bound of the ids in the queue
|
| int | minBoundId (void) const |
| | an id of least bound
|
| int | pop (void) |
| | removes the id of least key and returns it, in \( O( D \log_D s ) \) time
|
| int | popMinBound (void) |
| | removes the id of least bound and returns it, as pop() by the other heap
|
| void | clear (void) |
| | removes all the ids, in \( O( s ) \) time
|
template<class K, class Bd = K, unsigned D = 4>
class ADS::IndexedHeapPair< K, Bd, D >
the ids \( [ 0 , n ) \) by a key, the least on top, with the least of their bounds
◆ Bound
template<class K, class Bd = K, unsigned D = 4>
◆ Key
template<class K, class Bd = K, unsigned D = 4>
the type of the keys of selection
◆ IndexedHeapPair()
template<class K, class Bd = K, unsigned D = 4>
the empty queue of the ids \( [ 0 , n ) \)
- Precondition
- \( n \ge 0 \)
◆ bound()
template<class K, class Bd = K, unsigned D = 4>
the bound of an id in the queue
- Precondition
- the id is in the queue
◆ clear()
template<class K, class Bd = K, unsigned D = 4>
removes all the ids, in \( O( s ) \) time
◆ contains()
template<class K, class Bd = K, unsigned D = 4>
whether the id is in the queue
- Precondition
- \( \mathit{id} \in [ 0 , n ) \)
◆ empty()
template<class K, class Bd = K, unsigned D = 4>
whether the queue has no id
◆ erase()
template<class K, class Bd = K, unsigned D = 4>
removes the id from the queue, in \( O( D \log_D s ) \) time
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{erase}( \mathit{id} ) \cr
2 & \quad H_K.\mathrm{erase}( \mathit{id} );
\ H_B.\mathrm{erase}( \mathit{id} )
\end{array}}
\]
- Precondition
- the id is in the queue
◆ ids()
template<class K, class Bd = K, unsigned D = 4>
the number of ids, \( n \)
◆ key()
template<class K, class Bd = K, unsigned D = 4>
the key of an id in the queue
- Precondition
- the id is in the queue
◆ minBound()
template<class K, class Bd = K, unsigned D = 4>
the least bound of the ids in the queue
- Precondition
- the queue is not empty
◆ minBoundId()
template<class K, class Bd = K, unsigned D = 4>
an id of least bound
- Precondition
- the queue is not empty
◆ pop()
template<class K, class Bd = K, unsigned D = 4>
removes the id of least key and returns it, in \( O( D \log_D s ) \) time
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{pop}() \cr
2 & \quad \mathit{id} \gets H_K.\mathrm{pop}().\mathit{id};
\ H_B.\mathrm{erase}( \mathit{id} ) \cr
3 & \quad \textbf{return}\ \mathit{id}
\end{array}}
\]
- Precondition
- the queue is not empty
◆ popMinBound()
template<class K, class Bd = K, unsigned D = 4>
removes the id of least bound and returns it, as pop() by the other heap
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{popMinBound}() \cr
2 & \quad \mathit{id} \gets H_B.\mathrm{pop}().\mathit{id};
\ H_K.\mathrm{erase}( \mathit{id} );\ \textbf{return}
\ \mathit{id}
\end{array}}
\]
- Precondition
- the queue is not empty
◆ push()
template<class K, class Bd = K, unsigned D = 4>
inserts the id with the key \( k \) and the bound \( b \), in \( O( \log_D s ) \) time
In pseudocode (beyond the book), \( H_K \) and \( H_B \) the heaps by the keys and by the bounds:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{push}( \mathit{id} , k , b ) \cr
2 & \quad H_K.\mathrm{push}( \mathit{id} , k );
\ H_B.\mathrm{push}( \mathit{id} , b )
\end{array}}
\]
- Precondition
- \( \mathit{id} \in [ 0 , n ) \), not in the queue
◆ reset()
template<class K, class Bd = K, unsigned D = 4>
the empty queue of the ids \( [ 0 , n ) \), the room kept
- Precondition
- \( n \ge 0 \)
◆ size()
template<class K, class Bd = K, unsigned D = 4>
the number of ids in the queue, \( s \)
◆ top()
template<class K, class Bd = K, unsigned D = 4>
the id of least key
- Precondition
- the queue is not empty
◆ topKey()
template<class K, class Bd = K, unsigned D = 4>
the least key, that of top()
- Precondition
- the queue is not empty
◆ update()
template<class K, class Bd = K, unsigned D = 4>
sets the key of the id to \( k \) and its bound to \( b \), each heap moving the id up or down, in \( O( D \log_D s ) \) time
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{update}( \mathit{id} , k , b ) \cr
2 & \quad H_K.\mathrm{update}( \mathit{id} , k );
\ H_B.\mathrm{update}( \mathit{id} , b )
\end{array}}
\]
- Precondition
- the id is in the queue
The documentation for this class was generated from the following file: