SDSL  3.0.0
Succinct Data Structure Library
construct_isa.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_CONSTRUCT_ISA
9 #define INCLUDED_SDSL_CONSTRUCT_ISA
10 
11 #include <iostream>
12 #include <list>
13 #include <stdexcept>
14 
15 #include <sdsl/int_vector.hpp>
16 #include <sdsl/util.hpp>
17 
18 namespace sdsl
19 {
20 
21 inline void construct_isa(cache_config & config)
22 {
24  if (!cache_file_exists(conf::KEY_ISA, config))
25  { // if isa is not already on disk => calculate it
27  if (!sa_buf.is_open()) { throw std::ios_base::failure("cst_construct: Cannot load SA from file system!"); }
28  int_vector<> isa(sa_buf.size());
29  for (size_type i = 0; i < isa.size(); ++i) { isa[sa_buf[i]] = i; }
30  store_to_cache(isa, conf::KEY_ISA, config);
31  }
32 }
33 
34 } // namespace sdsl
35 
36 #endif
uint64_t size() const
Returns the number of elements currently stored.
bool is_open()
Returns whether underlying streams are currently associated to a file.
A generic vector class for integers of width .
Definition: int_vector.hpp:253
size_type size() const noexcept
The number of elements in the int_vector.
int_vector.hpp contains the sdsl::int_vector class.
constexpr char KEY_SA[]
Definition: config.hpp:37
constexpr char KEY_ISA[]
Definition: config.hpp:40
int_vector ::size_type size_type
Namespace for the succinct data structure library.
std::string cache_file_name(const std::string &key, const cache_config &config)
Returns the file name of the resource.
Definition: io.hpp:630
void construct_isa(cache_config &config)
bool cache_file_exists(const std::string &key, const cache_config &config)
Checks if the resource specified by the key exists in the cache.
Definition: io.hpp:672
bool store_to_cache(const T &v, const std::string &key, cache_config &config, bool add_type_hash=false)
Stores the object v as a resource in the cache.
Definition: io.hpp:737
Helper class for construction process.
Definition: config.hpp:67
util.hpp contains some helper methods for int_vector and other stuff like demangle class names.