SDSL  3.0.0
Succinct Data Structure Library
lcp.hpp
Go to the documentation of this file.
1 // Copyright (c) 2016, the SDSL Project Authors. All rights reserved.
2 // Please see the AUTHORS file for details. Use of this source code is governed
3 // by a BSD license that can be found in the LICENSE file.
8 #ifndef INCLUDED_SDSL_LCP
9 #define INCLUDED_SDSL_LCP
10 
11 #include <istream>
12 
13 #include <sdsl/construct_isa.hpp>
15 #include <sdsl/int_vector.hpp>
16 #include <sdsl/sdsl_concepts.hpp>
18 
20 namespace sdsl
21 {
22 
23 // construct lcp arrays
24 template <class t_lcp, class t_cst>
25 void construct_lcp(t_lcp & lcp, const t_cst & cst, cache_config & config)
26 {
27  typename t_lcp::lcp_category tag;
28  construct_lcp(lcp, cst, config, tag);
29 }
30 
31 template <class t_lcp, class t_cst>
32 void construct_lcp(t_lcp & lcp, const t_cst &, cache_config & config, lcp_plain_tag)
33 {
34  lcp = t_lcp(config);
35 }
36 
37 template <class t_lcp, class t_cst>
38 void construct_lcp(t_lcp & lcp, const t_cst & cst, cache_config & config, lcp_permuted_tag)
39 {
40  lcp = t_lcp(config, &(cst.csa));
41 }
42 
43 template <class t_lcp, class t_cst>
44 void construct_lcp(t_lcp & lcp, const t_cst & cst, cache_config & config, lcp_tree_compressed_tag)
45 {
46  lcp = t_lcp(config, &cst);
47 }
48 
49 template <class t_lcp, class t_cst>
50 void construct_lcp(t_lcp & lcp, const t_cst & cst, cache_config & config, lcp_tree_and_lf_compressed_tag)
51 {
52  lcp = t_lcp(config, &cst);
53 }
54 
55 // copy lcp arrays
56 template <class t_lcp, class t_cst>
57 void copy_lcp(t_lcp & lcp, const t_lcp & lcp_c, const t_cst & cst)
58 {
59  typename t_lcp::lcp_category tag;
60  copy_lcp(lcp, lcp_c, cst, tag);
61 }
62 
63 template <class t_lcp, class t_cst>
64 void copy_lcp(t_lcp & lcp, const t_lcp & lcp_c, const t_cst &, lcp_plain_tag)
65 {
66  lcp = lcp_c;
67 }
68 
69 template <class t_lcp, class t_cst>
70 void copy_lcp(t_lcp & lcp, const t_lcp & lcp_c, const t_cst & cst, lcp_permuted_tag)
71 {
72  lcp = lcp_c;
73  lcp.set_csa(&(cst.csa));
74 }
75 
76 template <class t_lcp, class t_cst>
77 void copy_lcp(t_lcp & lcp, const t_lcp & lcp_c, const t_cst & cst, lcp_tree_compressed_tag)
78 {
79  lcp = lcp_c;
80  lcp.set_cst(&cst);
81 }
82 
83 template <class t_lcp, class t_cst>
84 void copy_lcp(t_lcp & lcp, const t_lcp & lcp_c, const t_cst & cst, lcp_tree_and_lf_compressed_tag)
85 {
86  lcp = lcp_c;
87  lcp.set_cst(&cst);
88 }
89 
90 // move lcp arrays
91 template <class t_lcp, class t_cst>
92 void move_lcp(t_lcp && lcp, t_lcp && lcp_c, const t_cst & cst)
93 {
94  typename std::remove_reference<t_lcp>::type::lcp_category tag;
95  move_lcp(std::forward<t_lcp>(lcp), std::forward<t_lcp>(lcp_c), cst, tag);
96 }
97 
98 template <class t_lcp, class t_cst>
99 void move_lcp(t_lcp && lcp, t_lcp && lcp_c, const t_cst &, lcp_plain_tag)
100 {
101  lcp = std::move(lcp_c);
102 }
103 
104 template <class t_lcp, class t_cst>
105 void move_lcp(t_lcp && lcp, t_lcp && lcp_c, const t_cst & cst, lcp_permuted_tag)
106 {
107  lcp = std::move(lcp_c);
108  lcp.set_csa(&(cst.csa));
109 }
110 
111 template <class t_lcp, class t_cst>
112 void move_lcp(t_lcp && lcp, t_lcp && lcp_c, const t_cst & cst, lcp_tree_compressed_tag)
113 {
114  lcp = std::move(lcp_c);
115  lcp.set_cst(&cst);
116 }
117 
118 template <class t_lcp, class t_cst>
119 void move_lcp(t_lcp && lcp, t_lcp && lcp_c, const t_cst & cst, lcp_tree_and_lf_compressed_tag)
120 {
121  lcp = std::move(lcp_c);
122  lcp.set_cst(&cst);
123 }
124 
125 // load lcp arrays
126 template <class t_lcp, class t_cst>
127 void load_lcp(t_lcp & lcp, std::istream & in, const t_cst & cst)
128 {
129  typename t_lcp::lcp_category tag;
130  load_lcp(lcp, in, cst, tag);
131 }
132 
133 template <class t_lcp, class t_cst>
134 void load_lcp(t_lcp & lcp, std::istream & in, const t_cst &, lcp_plain_tag)
135 {
136  lcp.load(in);
137 }
138 
139 template <class t_lcp, class t_cst>
140 void load_lcp(t_lcp & lcp, std::istream & in, const t_cst & cst, lcp_permuted_tag)
141 {
142  lcp.load(in, &(cst.csa));
143 }
144 
145 template <class t_lcp, class t_cst>
146 void load_lcp(t_lcp & lcp, std::istream & in, const t_cst & cst, lcp_tree_compressed_tag)
147 {
148  lcp.load(in, &cst);
149 }
150 
151 template <class t_lcp, class t_cst>
152 void load_lcp(t_lcp & lcp, std::istream & in, const t_cst & cst, lcp_tree_and_lf_compressed_tag)
153 {
154  lcp.load(in, &cst);
155 }
156 
157 // set lcp pointers
158 template <class t_lcp, class t_cst>
159 void set_lcp_pointer(t_lcp & lcp, const t_cst & cst)
160 {
161  typename t_lcp::lcp_category tag;
162  set_lcp_pointer(lcp, cst, tag);
163 }
164 
165 template <class t_lcp, class t_cst>
166 void set_lcp_pointer(t_lcp &, const t_cst &, lcp_plain_tag)
167 {}
168 
169 template <class t_lcp, class t_cst>
170 void set_lcp_pointer(t_lcp & lcp, const t_cst & cst, lcp_permuted_tag)
171 {
172  lcp.set_csa(&(cst.csa));
173 }
174 
175 template <class t_lcp, class t_cst>
176 void set_lcp_pointer(t_lcp & lcp, const t_cst & cst, lcp_tree_compressed_tag)
177 {
178  lcp.set_cst(&cst);
179 }
180 
181 template <class t_lcp, class t_cst>
182 void set_lcp_pointer(t_lcp & lcp, const t_cst & cst, lcp_tree_and_lf_compressed_tag)
183 {
184  lcp.set_cst(&cst);
185 }
186 
187 } // end namespace sdsl
188 
189 // clang-format off
190 #include <sdsl/lcp_bitcompressed.hpp> // type (a)
191 #include <sdsl/lcp_byte.hpp> // type (a)
192 #include <sdsl/lcp_dac.hpp> // type (a)
193 #include <sdsl/lcp_support_sada.hpp> // type (b)
194 #include <sdsl/lcp_support_tree.hpp> // type (c)
195 #include <sdsl/lcp_support_tree2.hpp> // type (c)
196 #include <sdsl/lcp_vlc.hpp> // type (a)
197 #include <sdsl/lcp_wt.hpp> // type (a)
198 // clang-format on
199 
200 #endif
construct_isa.hpp contains a space and time efficient construction method for the inverse suffix arra...
csa_alphabet_strategy.hpp includes different strategy classes for representing an alphabet of a CSA.
int_vector.hpp contains the sdsl::int_vector class.
lcp_bitcompressed.hpp contains a bitcompressed LCP array.
lcp_byte.hpp contains a (compressed) lcp array.
lcp_dac.hpp contains an implementation of a (compressed) LCP array.
lcp_support_sada.hpp contains a compressed lcp array.
lcp_wt.hpp contains a (compressed) LCP array based on a WT.
Namespace for the succinct data structure library.
void move_lcp(t_lcp &&lcp, t_lcp &&lcp_c, const t_cst &cst)
Definition: lcp.hpp:92
void copy_lcp(t_lcp &lcp, const t_lcp &lcp_c, const t_cst &cst)
Definition: lcp.hpp:57
void construct_lcp(t_lcp &lcp, const t_cst &cst, cache_config &config)
Definition: lcp.hpp:25
void set_lcp_pointer(t_lcp &lcp, const t_cst &cst)
Definition: lcp.hpp:159
void load_lcp(t_lcp &lcp, std::istream &in, const t_cst &cst)
Definition: lcp.hpp:127
Contains declarations and definitions of data structure concepts.
select_support_mcl.hpp contains classes that support a sdsl::bit_vector with constant time select inf...
Helper class for construction process.
Definition: config.hpp:67