SDSL: Succinct Data Structure Library
A C++ template library for succinct data structures
 All Classes Namespaces Files Functions Variables Typedefs Friends
sdsl/include/sdsl/lcp.hpp
Go to the documentation of this file.
00001 /* sdsl - succinct data structures library
00002     Copyright (C) 2009 Simon Gog
00003 
00004     This program is free software: you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation, either version 3 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program.  If not, see http://www.gnu.org/licenses/ .
00016 */
00021 #ifndef INCLUDED_SDSL_LCP
00022 #define INCLUDED_SDSL_LCP
00023 
00024 #include "sdsl_concepts.hpp"
00025 
00026 #include "int_vector.hpp"
00027 #include "select_support_mcl.hpp"
00028 #include "isa_construct.hpp"
00029 #include <istream>
00030 
00032 namespace sdsl
00033 {
00034 
00035 // construct lcp arrays
00036 template<class Lcp, class Cst, uint8_t int_width, class size_type_class, uint8_t int_width1, class size_type_class1>
00037 void construct_lcp(Lcp& lcp, const Cst& cst,
00038                    int_vector_file_buffer<int_width, size_type_class>& lcp_buf,
00039                    int_vector_file_buffer<int_width1, size_type_class1>& isa_buf)
00040 {
00041     typename Lcp::lcp_category tag;
00042     construct_lcp(lcp, cst, lcp_buf, isa_buf, tag);
00043 }
00044 
00045 template<class Lcp, class Cst, uint8_t int_width, class size_type_class, uint8_t int_width1, class size_type_class1>
00046 void construct_lcp(Lcp& lcp, const Cst& cst,
00047                    int_vector_file_buffer<int_width, size_type_class>& lcp_buf,
00048                    int_vector_file_buffer<int_width1, size_type_class1>& isa_buf,
00049                    lcp_plain_tag)
00050 {
00051     lcp.construct(lcp_buf);
00052 }
00053 
00054 template<class Lcp, class Cst, uint8_t int_width, class size_type_class, uint8_t int_width1, class size_type_class1>
00055 void construct_lcp(Lcp& lcp, const Cst& cst,
00056                    int_vector_file_buffer<int_width, size_type_class>& lcp_buf,
00057                    int_vector_file_buffer<int_width1, size_type_class1>& isa_buf,
00058                    lcp_permuted_tag)
00059 {
00060     lcp.construct(lcp_buf, isa_buf, &(cst.csa));
00061 }
00062 
00063 template<class Lcp, class Cst, uint8_t int_width, class size_type_class, uint8_t int_width1, class size_type_class1>
00064 void construct_lcp(Lcp& lcp, const Cst& cst,
00065                    int_vector_file_buffer<int_width, size_type_class>& lcp_buf,
00066                    int_vector_file_buffer<int_width1, size_type_class1>& isa_buf,
00067                    lcp_tree_compressed_tag)
00068 {
00069     lcp.construct(lcp_buf, &(cst.bp_support), &(cst.first_child_rank));
00070 }
00071 
00072 // construct lcp arrays
00073 template<class Lcp, class Cst>
00074 void construct_lcp(Lcp& lcp, const Cst& cst, tMSS& file_map, const std::string dir, const std::string id)
00075 {
00076     typename Lcp::lcp_category tag;
00077     construct_lcp(lcp, cst, file_map, dir, id, tag);
00078 }
00079 
00080 template<class Lcp, class Cst>
00081 void construct_lcp(Lcp& lcp, const Cst& cst, tMSS& file_map, const std::string dir, const std::string id, lcp_plain_tag)
00082 {
00083     int_vector_file_buffer<> lcp_buf(file_map["lcp"].c_str());
00084     lcp.construct(lcp_buf);
00085 }
00086 
00087 template<class Lcp, class Cst>
00088 void construct_lcp(Lcp& lcp, const Cst& cst, tMSS& file_map, const std::string dir, const std::string id, lcp_permuted_tag)
00089 {
00090     int_vector_file_buffer<> lcp_buf(file_map["lcp"].c_str());
00091     if (file_map.find("isa") == file_map.end()) {
00092         construct_isa(file_map, dir, id);
00093     }
00094     int_vector_file_buffer<> isa_buf(file_map["isa"].c_str());
00095     lcp.construct(lcp_buf, isa_buf, &(cst.csa));
00096 }
00097 
00098 template<class Lcp, class Cst>
00099 void construct_lcp(Lcp& lcp, const Cst& cst, tMSS& file_map, const std::string dir, const std::string id, lcp_tree_compressed_tag)
00100 {
00101     int_vector_file_buffer<> lcp_buf(file_map["lcp"].c_str());
00102     lcp.construct(lcp_buf, &cst);
00103 }
00104 
00105 template<class Lcp, class Cst>
00106 void construct_lcp(Lcp& lcp, const Cst& cst, tMSS& file_map, const std::string dir, const std::string id, lcp_tree_and_lf_compressed_tag)
00107 {
00108     int_vector_file_buffer<> lcp_buf(file_map["lcp"].c_str());
00109     int_vector_file_buffer<8> bwt_buf(file_map["bwt"].c_str());
00110     lcp.construct(lcp_buf, bwt_buf, &cst);
00111 }
00112 
00113 // copy lcp arrays
00114 template<class Lcp, class Cst>
00115 void copy_lcp(Lcp& lcp, const Lcp& lcp_c, const Cst& cst)
00116 {
00117     typename Lcp::lcp_category tag;
00118     copy_lcp(lcp, lcp_c, cst, tag);
00119 }
00120 
00121 template<class Lcp, class Cst>
00122 void copy_lcp(Lcp& lcp, const Lcp& lcp_c, const Cst& cst, lcp_plain_tag)
00123 {
00124     lcp = lcp_c;
00125 }
00126 
00127 template<class Lcp, class Cst>
00128 void copy_lcp(Lcp& lcp, const Lcp& lcp_c, const Cst& cst, lcp_permuted_tag)
00129 {
00130     lcp = lcp_c;
00131     lcp.set_csa(&(cst.csa));
00132 }
00133 
00134 template<class Lcp, class Cst>
00135 void copy_lcp(Lcp& lcp, const Lcp& lcp_c, const Cst& cst, lcp_tree_compressed_tag)
00136 {
00137     lcp = lcp_c;
00138     lcp.set_cst(&cst);
00139 }
00140 
00141 template<class Lcp, class Cst>
00142 void copy_lcp(Lcp& lcp, const Lcp& lcp_c, const Cst& cst, lcp_tree_and_lf_compressed_tag)
00143 {
00144     lcp = lcp_c;
00145     lcp.set_cst(&cst);
00146 }
00147 
00148 // swap lcp arrays
00149 template<class Lcp, class Cst>
00150 void swap_lcp(Lcp& lcp1, Lcp& lcp2, const Cst& cst1, const Cst& cst2)
00151 {
00152     typename Lcp::lcp_category tag;
00153     swap_lcp(lcp1, lcp2, cst1, cst2, tag);
00154 }
00155 
00156 template<class Lcp, class Cst>
00157 void swap_lcp(Lcp& lcp1, Lcp& lcp2, const Cst& cst1, const Cst& cst2, lcp_plain_tag)
00158 {
00159     lcp1.swap(lcp2);
00160 }
00161 
00162 template<class Lcp, class Cst>
00163 void swap_lcp(Lcp& lcp1, Lcp& lcp2, const Cst& cst1, const Cst& cst2, lcp_permuted_tag)
00164 {
00165     lcp1.swap(lcp2);
00166     lcp1.set_csa(&(cst1.csa));
00167     lcp2.set_csa(&(cst2.csa));
00168 }
00169 
00170 template<class Lcp, class Cst>
00171 void swap_lcp(Lcp& lcp1, Lcp& lcp2, const Cst& cst1, const Cst& cst2, lcp_tree_compressed_tag)
00172 {
00173     lcp1.swap(lcp2);
00174     lcp1.set_cst(&cst1);
00175     lcp2.set_cst(&cst2);
00176 }
00177 
00178 template<class Lcp, class Cst>
00179 void swap_lcp(Lcp& lcp1, Lcp& lcp2, const Cst& cst1, const Cst& cst2, lcp_tree_and_lf_compressed_tag)
00180 {
00181     lcp1.swap(lcp2);
00182     lcp1.set_cst(&cst1);
00183     lcp2.set_cst(&cst2);
00184 }
00185 
00186 // load lcp arrays
00187 template<class Lcp, class Cst>
00188 void load_lcp(Lcp& lcp, std::istream& in, const Cst& cst)
00189 {
00190     typename Lcp::lcp_category tag;
00191     load_lcp(lcp, in, cst, tag);
00192 }
00193 
00194 template<class Lcp, class Cst>
00195 void load_lcp(Lcp& lcp, std::istream& in, const Cst& cst, lcp_plain_tag)
00196 {
00197     lcp.load(in);
00198 }
00199 
00200 template<class Lcp, class Cst>
00201 void load_lcp(Lcp& lcp, std::istream& in, const Cst& cst, lcp_permuted_tag)
00202 {
00203     lcp.load(in, &(cst.csa));
00204 }
00205 
00206 template<class Lcp, class Cst>
00207 void load_lcp(Lcp& lcp, std::istream& in, const Cst& cst, lcp_tree_compressed_tag)
00208 {
00209     lcp.load(in, &cst);
00210 }
00211 
00212 template<class Lcp, class Cst>
00213 void load_lcp(Lcp& lcp, std::istream& in, const Cst& cst, lcp_tree_and_lf_compressed_tag)
00214 {
00215     lcp.load(in, &cst);
00216 }
00217 
00218 } // end namespace sdsl
00219 
00220 #include "lcp_support_sada.hpp"     // type (b)
00221 #include "lcp_kurtz.hpp"            // type (a)
00222 #include "lcp_wt.hpp"               // type (a)
00223 #include "lcp_dac.hpp"              // type (a)
00224 #include "lcp_bitcompressed.hpp"    // type (a)
00225 #include "lcp_support_tree.hpp"     // type (c)
00226 #include "lcp_support_tree2.hpp"    // type (c)
00227 
00228 
00229 #endif