a trie of strings with the bitmaps of the children, the list of the strings and the smallest and largest string below each node
More...
#include <ADS/dictionary/BitmapTrie.h>
|
| | BitmapTrie (void) |
| | the empty trie
|
| | BitmapTrie (BitmapTrie &&o) |
| | the trie of o, which is left empty
|
| BitmapTrie & | operator= (BitmapTrie &&o) noexcept |
| | the trie of o, which gets the strings of this one
|
| | BitmapTrie (const BitmapTrie &)=delete |
| BitmapTrie & | operator= (const BitmapTrie &)=delete |
| | ~BitmapTrie () |
| | frees the nodes and the strings
|
| const std::string * | lowerBound (std::string_view s) const |
| | the smallest string \( \ge s \), nil if none (the find( s ) of the SSet of Morin's book), in \( O( |s| ) \) time
|
| const std::string * | find (std::string_view s) const |
| | the string \( s \), nil if it is not there, in \( O( |s| ) \) time
|
| std::optional< V > | lookup (std::string_view s) const |
| | the value of \( s \), or nothing, in \( O( |s| ) \) time
|
| bool | contains (std::string_view s) const |
| | true if \( s \) is there, in \( O( |s| ) \) time
|
| bool | insert (std::string_view s, const V &v=V()) |
| | associates \( v \) to \( s \); true if \( s \) was not there, in \( O( |s| ) \) time
|
| bool | remove (std::string_view s) |
| | removes \( s \); true if it was there, in \( O( |s| ) \) time
|
| std::size_t | size (void) const |
| | the number of strings
|
| bool | empty (void) const |
| | true if there are no strings
|
| std::size_t | nodes (void) const |
| | the number of nodes, the root included
|
| const_iterator | begin (void) const |
| | the iterator on the smallest string
|
| const_iterator | end (void) const |
| | the iterator past the largest string
|
| const_iterator | cbegin (void) const |
| | as begin()
|
| const_iterator | cend (void) const |
| | as end()
|
| const_iterator | seek (std::string_view s) const |
| | the iterator on the smallest string \( \ge s \), end() if none
|
template<class V = std::monostate>
class ADS::BitmapTrie< V >
a trie of strings with the bitmaps of the children, the list of the strings and the smallest and largest string below each node
◆ const_reference
template<class V = std::monostate>
a pair of references, by value
◆ difference_type
template<class V = std::monostate>
the type of the distances between two iterators
◆ Item
template<class V = std::monostate>
the items of the SSet, the strings
◆ iterator
template<class V = std::monostate>
the iterator on the items
◆ Key
template<class V = std::monostate>
◆ reference
template<class V = std::monostate>
a pair of references, by value
◆ size_type
template<class V = std::monostate>
◆ Value
template<class V = std::monostate>
◆ value_type
template<class V = std::monostate>
the type of the items, for the standard library
◆ BitmapTrie() [1/3]
template<class V = std::monostate>
◆ BitmapTrie() [2/3]
template<class V = std::monostate>
the trie of o, which is left empty
◆ BitmapTrie() [3/3]
template<class V = std::monostate>
◆ ~BitmapTrie()
template<class V = std::monostate>
frees the nodes and the strings
◆ begin()
template<class V = std::monostate>
the iterator on the smallest string
◆ cbegin()
template<class V = std::monostate>
◆ cend()
template<class V = std::monostate>
◆ contains()
template<class V = std::monostate>
true if \( s \) is there, in \( O( |s| ) \) time
◆ empty()
template<class V = std::monostate>
true if there are no strings
◆ end()
template<class V = std::monostate>
the iterator past the largest string
◆ find()
template<class V = std::monostate>
the string \( s \), nil if it is not there, in \( O( |s| ) \) time
◆ insert()
template<class V = std::monostate>
| bool ADS::BitmapTrie< V >::insert |
( |
std::string_view | s, |
|
|
const V & | v = V() ) |
associates \( v \) to \( s \); true if \( s \) was not there, in \( O( |s| ) \) time
In pseudocode (exercise 13.3 of Morin's book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{insert}( s , v ) \cr
2 & \quad \textbf{if}\ s \text{ is there}\ \textbf{then}\ \text{give it }
\text{the value } v;\ \textbf{return false} \cr
3 & \quad \text{link } s \text{ before the string of }
\mathrm{lowerBound}( s ) \text{, add the missing nodes of its path}
\cr
4 & \quad \textbf{for}\ i \gets |s|\ \textbf{downto}\ 0\ \textbf{do}
\quad \triangleright\ u \text{ the node of depth } i \cr
5 & \qquad \textbf{if}\ \text{nothing of } u \text{ precedes the path }
\text{of } s \text{ and } s \text{ is the } \mathit{min} \text{ of }
\text{the next node}\ \textbf{then}\ u.\mathit{min} \gets s \cr
6 & \qquad \textbf{if}\ \text{nothing of } u \text{ follows the path }
\text{of } s \text{ and } s \text{ is the } \mathit{max} \text{ of }
\text{the next node}\ \textbf{then}\ u.\mathit{max} \gets s \cr
7 & \quad \textbf{return true}
\end{array}}
\]
- Postcondition
- \( s \) is there
◆ lookup()
template<class V = std::monostate>
| std::optional< V > ADS::BitmapTrie< V >::lookup |
( |
std::string_view | s | ) |
const |
|
nodiscard |
the value of \( s \), or nothing, in \( O( |s| ) \) time
◆ lowerBound()
template<class V = std::monostate>
| const std::string * ADS::BitmapTrie< V >::lowerBound |
( |
std::string_view | s | ) |
const |
|
nodiscard |
the smallest string \( \ge s \), nil if none (the find( s ) of the SSet of Morin's book), in \( O( |s| ) \) time
In pseudocode (exercise 13.3 of Morin's book), \( u.\mathit{min} \) and \( u.\mathit{max} \) the smallest and the largest string below \( u \):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{lowerBound}( s ) \cr
2 & \quad u \gets \mathit{root} \cr
3 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ |s| - 1\ \textbf{do} \cr
4 & \qquad \textbf{if}\ u \text{ has a child of } s_i\ \textbf{then}
\ u \gets \text{that child};\ \textbf{continue} \cr
5 & \qquad \textbf{if}\ u \text{ has a child of a byte} > s_i
\ \textbf{then return}\ \text{the } \mathit{min} \text{ of the }
\text{first one} \cr
6 & \qquad \textbf{return}\ u.\mathit{max}.\mathit{next} \cr
7 & \quad \textbf{return}\ u.\mathit{min}
\end{array}}
\]
◆ nodes()
template<class V = std::monostate>
the number of nodes, the root included
◆ operator=() [1/2]
template<class V = std::monostate>
the trie of o, which gets the strings of this one
◆ operator=() [2/2]
template<class V = std::monostate>
◆ remove()
template<class V = std::monostate>
removes \( s \); true if it was there, in \( O( |s| ) \) time
In pseudocode (exercise 13.3 of Morin's book), \( \ell \) the item of \( s \) in the list:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{remove}( s ) \cr
2 & \quad \textbf{if}\ s \text{ is not there}\ \textbf{then return false}
\cr
3 & \quad \text{unlink } \ell;\ \text{remove the nodes of the path of }
s \text{ left with no string below} \cr
4 & \quad \textbf{foreach}\ \text{node } u \text{ left on the path}
\ \textbf{do} \cr
5 & \qquad \textbf{if}\ u.\mathit{min} = \ell\ \textbf{then}
\ u.\mathit{min} \gets \ell.\mathit{next} \cr
6 & \qquad \textbf{if}\ u.\mathit{max} = \ell\ \textbf{then}
\ u.\mathit{max} \gets \ell.\mathit{prev} \cr
7 & \quad \textbf{return true}
\end{array}}
\]
- Postcondition
- \( s \) is not there
◆ seek()
template<class V = std::monostate>
the iterator on the smallest string \( \ge s \), end() if none
◆ size()
template<class V = std::monostate>
The documentation for this class was generated from the following file: