SDSL 3.0.3
Succinct Data Structure Library
Loading...
Searching...
No Matches
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 <memory>
13
14#include <sdsl/config.hpp>
15#include <sdsl/int_vector.hpp>
17#include <sdsl/io.hpp>
18
19namespace sdsl
20{
21
22inline void construct_isa(cache_config & config)
23{
25 if (!cache_file_exists(conf::KEY_ISA, config))
26 { // if isa is not already on disk => calculate it
28 if (!sa_buf.is_open())
29 {
30 throw std::ios_base::failure("cst_construct: Cannot load SA from file system!");
31 }
32 int_vector<> isa(sa_buf.size());
33 for (size_type i = 0; i < isa.size(); ++i)
34 {
35 isa[sa_buf[i]] = i;
36 }
37 store_to_cache(isa, conf::KEY_ISA, config);
38 }
39}
40
41} // namespace sdsl
42
43#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 .
int_vector< 64 >::size_type size() const noexcept
int_vector.hpp contains the sdsl::int_vector class.
int_vector_buffer.hpp contains the sdsl::int_vector_buffer class.
io.hpp contains some methods for reading/writing sdsl structures.
constexpr char KEY_SA[]
Definition config.hpp:36
constexpr char KEY_ISA[]
Definition config.hpp:39
Namespace for the succinct data structure library.
bool store_to_cache(T const &v, std::string const &key, cache_config &config, bool add_type_hash=false)
Stores the object v as a resource in the cache.
Definition io.hpp:804
bool cache_file_exists(std::string const &key, cache_config const &config)
Checks if the resource specified by the key exists in the cache.
Definition io.hpp:733
std::string cache_file_name(std::string const &key, cache_config const &config)
Returns the file name of the resource.
Definition io.hpp:688
void construct_isa(cache_config &config)
Helper class for construction process.
Definition config.hpp:66