the table with direct access of the keys in \( [ a , b ] \), \( H( k ) = k - a \): every operation in \( O( 1 ) \) time, \( b - a + 1 \) places of memory
More...
#include <ADS/dictionary/DirectTable.h>
|
| | DirectTable (long a, long b) |
| | the empty table of the keys in \( [ a , b ] \)
|
| std::optional< V > | lookup (long k) const |
| | the value of \( k \), the place \( A[ k - a ] \), or nothing
|
| void | insert (long k, const V &v) |
| | associates \( v \) to \( k \), writing it in \( A[ k - a ] \)
|
| void | remove (long k) |
| | removes \( k \), if it is there, emptying \( A[ k - a ] \)
|
| std::size_t | size (void) const |
| | the number of keys
|
| std::size_t | capacity (void) const |
| | the size \( m = b - a + 1 \) of the vector
|
| const_iterator | begin (void) const |
| | the iterator on the first item
|
| const_iterator | end (void) const |
| | the iterator past the last item
|
| const_iterator | cbegin (void) const |
| | the constant iterator on the first item
|
| const_iterator | cend (void) const |
| | the constant iterator past the last item
|
template<class V>
class ADS::DirectTable< V >
the table with direct access of the keys in \( [ a , b ] \), \( H( k ) = k - a \): every operation in \( O( 1 ) \) time, \( b - a + 1 \) places of memory
◆ const_iterator
the iterator on the items, constant
◆ const_reference
a constant reference to an item
◆ difference_type
the type of the distances between two iterators
◆ iterator
the iterator on the items
◆ Key
◆ key_type
◆ mapped_type
◆ reference
◆ size_type
◆ Value
◆ value_type
the type of the items, for the standard library
◆ DirectTable()
the empty table of the keys in \( [ a , b ] \)
- Precondition
- \( a \le b \), and \( b - a + 1 \) places fit in a std::size_t (not the whole range of long)
◆ begin()
the iterator on the first item
◆ capacity()
the size \( m = b - a + 1 \) of the vector
◆ cbegin()
the constant iterator on the first item
◆ cend()
the constant iterator past the last item
◆ end()
the iterator past the last item
◆ insert()
associates \( v \) to \( k \), writing it in \( A[ k - a ] \)
- Precondition
- \( k \in [ a , b ] \)
- Postcondition
- lookup( k ) is \( v \)
◆ lookup()
the value of \( k \), the place \( A[ k - a ] \), or nothing
In pseudocode (chapter 7), \( A[ 0 .. m - 1 ] \) the places, each empty (nil) or holding a value, and \( n \) the places not empty:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{lookup}( k )\quad \triangleright
\ \text{the key } k \text{ in the cell } k - a \cr
2 & \quad \textbf{return}\ A[ k - a ]\quad \triangleright\ \textbf{nil}
\text{ if } k \text{ is absent} \cr
3 & \textbf{procedure}\ \mathrm{insert}( k , v ) \cr
4 & \quad n \gets n + [ A[ k - a ] = \textbf{nil} ];\ A[ k - a ] \gets v
\cr
5 & \textbf{procedure}\ \mathrm{remove}( k ) \cr
6 & \quad n \gets n - [ A[ k - a ] \ne \textbf{nil} ];\ A[ k - a ] \gets
\textbf{nil}
\end{array}}
\]
- Precondition
- \( k \in [ a , b ] \)
◆ remove()
removes \( k \), if it is there, emptying \( A[ k - a ] \)
- Precondition
- \( k \in [ a , b ] \)
- Postcondition
- lookup( k ) is nothing
◆ size()
The documentation for this class was generated from the following file: