Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
PositionHeapNaive.h
Go to the documentation of this file.
1
6#pragma once
7
9#include <string/LinearString.h>
11
12namespace stringology {
13
14namespace indexing {
15
24public:
30 template < class SymbolType >
32
33};
34
35template < class SymbolType >
37 if ( w.getContent ( ).empty ( ) )
38 throw exception::CommonException ( "Position heap can't index empty string" );
39
41
42 for ( unsigned i = w.getContent ( ).size ( ) - 1; i > 0; i-- ) {
43 unsigned k = i - 1;
45
46 while ( n->getChildren ( ).count ( w.getContent ( )[k] ) )
47 n = & n->getChildren ( ).find ( w.getContent ( )[k++] )->second;
48
49 unsigned node = w.getContent ( ).size ( ) - i + 1;
50 n = & n->getChildren ( ).insert ( std::make_pair ( w.getContent ( )[k], ext::trie < SymbolType, unsigned > ( node ) ) ).first->second;
51 }
52
54}
55
56} /* namespace indexing */
57
58} /* namespace stringology */
59
Basic exception from which all other exceptions are derived.
Definition: CommonException.h:21
Class introducing a trie with interface trying to be close to the interface of standard library conta...
Definition: trie.hpp:47
ext::map< Key, trie > & getChildren()
Getter of children of the root node.
Definition: trie.hpp:115
Position heap string index. Tree like representation of all suffixes. The suffixes are themselves rep...
Definition: PositionHeap.h:56
Linear string.
Definition: LinearString.h:57
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: PositionHeapNaive.h:23
static indexes::stringology::PositionHeap< SymbolType > construct(const string::LinearString< SymbolType > &w)
Definition: PositionHeapNaive.h:36
int i
Definition: AllEpsilonClosure.h:118
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: Node.cpp:11
Definition: ArithmeticCompression.h:18