Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
NonlinearFullAndLinearIndex.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
26#include <alib/string>
27
29
31
33
34namespace indexes {
35
36namespace arbology {
37
38class GeneralAlphabet;
39
49template < class SymbolType = DefaultSymbolType, template < typename > class StringIndex = indexes::stringology::PositionHeap >
54 StringIndex < common::ranked_symbol < SymbolType > > m_StringIndex;
55
59 ext::vector < int > m_JumpTable;
60
65
66public:
75
81 const StringIndex < common::ranked_symbol < SymbolType > > & getStringIndex ( ) const &;
82
88 StringIndex < common::ranked_symbol < SymbolType > > && getStringIndex ( ) &&;
89
95 const ext::vector < int > & getJumps ( ) const &;
96
103
109 const ext::vector < unsigned > & getRepeats ( ) const &;
110
117
124 return m_StringIndex.getAlphabet ( );
125 }
126
133 return std::move ( m_StringIndex.getAlphabet ( ) );
134 }
135
141 void setStringIndex ( StringIndex < common::ranked_symbol < SymbolType > > stringIndex );
142
149 return m_StringIndex.removeSymbolFromAlphabet ( symbol );
150 }
151
159 auto operator <=> ( const NonlinearFullAndLinearIndex & other ) const {
160 return std::tie ( getStringIndex ( ), getJumps ( ), getRepeats ( ) ) <=> std::tie ( other.getStringIndex ( ), other.getJumps ( ), other.getRepeats ( ) );
161 }
162
170 bool operator == ( const NonlinearFullAndLinearIndex & other ) const {
171 return std::tie ( getStringIndex ( ), getJumps ( ), getRepeats ( ) ) == std::tie ( other.getStringIndex ( ), other.getJumps ( ), other.getRepeats ( ) );
172 }
173
183 return out << "(NonlinearFullAndLinearIndex " << instance.m_StringIndex << ", " << instance.m_JumpTable << ")";
184 }
185};
186
187} /* namespace arbology */
188
189} /* namespace indexes */
190
191namespace indexes {
192
193namespace arbology {
194
195template < class SymbolType, template < typename > class StringIndex >
196NonlinearFullAndLinearIndex < SymbolType, StringIndex >::NonlinearFullAndLinearIndex ( StringIndex < common::ranked_symbol < SymbolType > > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ) : m_StringIndex ( std::move ( stringIndex ) ), m_JumpTable ( std::move ( jumpTable ) ), m_Repeats ( std::move ( repeats ) ) {
197}
198
199template < class SymbolType, template < typename > class StringIndex >
200const StringIndex < common::ranked_symbol < SymbolType > > & NonlinearFullAndLinearIndex < SymbolType, StringIndex >::getStringIndex ( ) const & {
201 return m_StringIndex;
202}
203
204template < class SymbolType, template < typename > class StringIndex >
205StringIndex < common::ranked_symbol < SymbolType > > && NonlinearFullAndLinearIndex < SymbolType, StringIndex >::getStringIndex ( ) && {
206 return std::move ( m_StringIndex );
207}
208
209template < class SymbolType, template < typename > class StringIndex >
211 return m_JumpTable;
212}
213
214template < class SymbolType, template < typename > class StringIndex >
216 return std::move ( m_JumpTable );
217}
218
219template < class SymbolType, template < typename > class StringIndex >
221 return m_Repeats;
222}
223
224template < class SymbolType, template < typename > class StringIndex >
226 return std::move ( m_Repeats );
227}
228
229template < class SymbolType, template < typename > class StringIndex >
230void NonlinearFullAndLinearIndex < SymbolType, StringIndex >::setStringIndex ( StringIndex < common::ranked_symbol < SymbolType > > stringIndex ) {
231 this->m_StringIndex = std::move ( stringIndex );
232}
233
234} /* namespace arbology */
235
236} /* namespace indexes */
237
238namespace core {
239
245template < class SymbolType, template < typename > class StringIndex >
246struct normalize < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, StringIndex > > {
248 StringIndex < common::ranked_symbol < > > stringIndex = core::normalize < StringIndex < common::ranked_symbol < SymbolType > > >::eval ( std::move ( value ).getStringIndex ( ) );
249
250 return indexes::arbology::NonlinearFullAndLinearIndex < > ( std::move ( stringIndex ), std::move ( value ).getJumps ( ), std::move ( value ).getRepeats ( ) );
251 }
252};
253
254} /* namespace core */
255
Definition: ranked_symbol.hpp:20
Definition: ostream.h:14
Definition: set.hpp:44
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Full and linear tree index. The index serves as a adaptor of string index so that searching for tree ...
Definition: NonlinearFullAndLinearIndex.h:50
NonlinearFullAndLinearIndex(StringIndex< common::ranked_symbol< SymbolType > > stringIndex, ext::vector< int > jumpTable, ext::vector< unsigned > repeats)
Definition: NonlinearFullAndLinearIndex.h:196
bool operator==(const NonlinearFullAndLinearIndex &other) const
Definition: NonlinearFullAndLinearIndex.h:170
friend ext::ostream & operator<<(ext::ostream &out, const NonlinearFullAndLinearIndex &instance)
Definition: NonlinearFullAndLinearIndex.h:182
void setStringIndex(StringIndex< common::ranked_symbol< SymbolType > > stringIndex)
Definition: NonlinearFullAndLinearIndex.h:230
auto operator<=>(const NonlinearFullAndLinearIndex &other) const
Definition: NonlinearFullAndLinearIndex.h:159
ext::set< common::ranked_symbol< SymbolType > > && getAlphabet() &&
Definition: NonlinearFullAndLinearIndex.h:132
const ext::set< common::ranked_symbol< SymbolType > > & getAlphabet() const &
Definition: NonlinearFullAndLinearIndex.h:123
bool removeSymbolFromAlphabet(const common::ranked_symbol< SymbolType > &symbol)
Definition: NonlinearFullAndLinearIndex.h:148
const ext::vector< unsigned > & getRepeats() const &
Definition: NonlinearFullAndLinearIndex.h:220
const StringIndex< common::ranked_symbol< SymbolType > > & getStringIndex() const &
Definition: NonlinearFullAndLinearIndex.h:200
const ext::vector< int > & getJumps() const &
Definition: NonlinearFullAndLinearIndex.h:210
Position heap string index. Tree like representation of all suffixes. The suffixes are themselves rep...
Definition: PositionHeap.h:56
Definition: BoyerMooreHorspool.h:22
Definition: normalize.hpp:10
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218
Definition: CompressedBitParallelTreeIndex.h:40
static indexes::arbology::NonlinearFullAndLinearIndex< > eval(indexes::arbology::NonlinearFullAndLinearIndex< SymbolType, StringIndex > &&value)
Definition: NonlinearFullAndLinearIndex.h:247
Definition: normalize.hpp:13