ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
LongestCommonExtension.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------- File LongestCommonExtension.h -----------------------*/
3/*--------------------------------------------------------------------------*/
95/*--------------------------------------------------------------------------*/
96/*----------------------------- DEFINITIONS --------------------------------*/
97/*--------------------------------------------------------------------------*/
98
99#ifndef __ADS_LongestCommonExtension
100 #define __ADS_LongestCommonExtension
101/* self-identification: #endif constant */
102
103/*--------------------------------------------------------------------------*/
104/*------------------------------ INCLUDES ----------------------------------*/
105/*--------------------------------------------------------------------------*/
106
107#include "ADS/Contract.h"
108#include "ADS/Portable.h"
109#include "ADS/SimdInline.h"
110#include "ADS/memory/Prefetch.h"
112
113#include <concepts>
114#include <cstddef>
115#include <cstdint>
116#include <string>
117#include <string_view>
118#include <vector>
119
120/*--------------------------------------------------------------------------*/
121/*--------------------------- NAMESPACE ------------------------------------*/
122/*--------------------------------------------------------------------------*/
123
124namespace ADS
125{
126
127/*--------------------------------------------------------------------------*/
128/*---------------------------- LceIndex ------------------------------------*/
129/*--------------------------------------------------------------------------*/
130
133template< class I = std::uint32_t >
134 requires( std::same_as< I , std::uint32_t > ||
135 std::same_as< I , std::uint64_t > )
137{
138
139/*--------------------------------------------------------------------------*/
140/*----------------------- PUBLIC PART OF THE CLASS -------------------------*/
141/*--------------------------------------------------------------------------*/
142
143 public:
173 explicit LceIndex( std::string_view T );
174
202 [[nodiscard]] std::size_t lce( std::size_t i , std::size_t j ) const;
203
205 [[nodiscard]] std::size_t size( void ) const { return( f_T.size() ); }
206
207/*--------------------------------------------------------------------------*/
208/*--------------------- PRIVATE PART OF THE CLASS --------------------------*/
209/*--------------------------------------------------------------------------*/
210
211 private:
213 ADS_NOINLINE [[nodiscard]] std::size_t longer( std::size_t i , std::size_t j ,
214 std::size_t far ) const;
215
217 [[nodiscard]] I minimum( std::size_t a , std::size_t c ) const;
218
219 std::string f_T;
220 std::size_t f_n = 0;
221 std::vector< I > f_rank;
222 std::vector< I > f_line;
223 std::size_t f_shift = 0;
224 std::vector< std::uint16_t > f_word;
225 std::vector< I > f_inner;
226 std::vector< I > f_top;
227 std::size_t f_blocks = 0;
228 std::size_t f_groups = 0;
229
230 }; // end( class LceIndex )
231
232/*--------------------------------------------------------------------------*/
233
234} // end( namespace ADS )
235
236/*--------------------------------------------------------------------------*/
237/*-------------------------- IMPLEMENTATION --------------------------------*/
238/*--------------------------------------------------------------------------*/
239
240#include "ADS/string/impl/LongestCommonExtension.tpp"
241
242/*--------------------------------------------------------------------------*/
243
244#endif /* LongestCommonExtension.h included */
245
246/*--------------------------------------------------------------------------*/
247/*-------------------- End File LongestCommonExtension.h -------------------*/
248/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The primitives of the processor that the compilers spell each in their own way, in one form for all: ...
The prefetch of a line of the cache, beyond the book: ADS::prefetch( p ) asks the processor to bring ...
The vector kernels of ADS that are inlined in the middle of a search, on Google Highway,...
The engineered construction of the suffix array and of its LCP array, beyond the book: the ones that ...
std::size_t lce(std::size_t i, std::size_t j) const
the length of the longest common prefix of the suffixes and
std::size_t size(void) const
the length of the text
Definition LongestCommonExtension.h:205
LceIndex(std::string_view T)
the index of (a copy of it), in time but for the sparse table of the groups
#define ADS_NOINLINE
a function never inlined
Definition Portable.h:99
Definition ADT.h:96