SDSL 3.0.2
Succinct Data Structure Library
Loading...
Searching...
No Matches
lcp_bitcompressed.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_BITCOMPRESSED
9#define INCLUDED_SDSL_LCP_BITCOMPRESSED
10
11#include <iosfwd>
12#include <stddef.h>
13#include <stdint.h>
14#include <string>
15
16#include <sdsl/cereal.hpp>
17#include <sdsl/config.hpp>
18#include <sdsl/int_vector.hpp>
20#include <sdsl/io.hpp>
21#include <sdsl/iterators.hpp>
24#include <sdsl/util.hpp>
25
26namespace sdsl
27{
28
29template <uint8_t t_width = 0>
31{
32public:
40 typedef const pointer const_pointer;
41 typedef ptrdiff_t difference_type;
42
45
46 enum
47 {
50 sa_order = 1
51 };
52
53 template <class Cst>
55
56private:
58
59public:
67
70 {
71 std::string lcp_file = cache_file_name(conf::KEY_LCP, config);
72 int_vector_buffer<> lcp_buf(lcp_file);
73 m_lcp = int_vector<t_width>(lcp_buf.size(), 0, lcp_buf.width());
74 for (size_type i = 0; i < m_lcp.size(); ++i)
75 {
76 m_lcp[i] = lcp_buf[i];
77 }
78 }
79
82 {
83 return m_lcp.size();
84 }
85
88 {
90 }
91
93 bool empty() const
94 {
95 return m_lcp.empty();
96 }
97
100 {
101 return const_iterator(this, 0);
102 }
103
106 {
107 return const_iterator(this, size());
108 }
109
111
114 {
115 return m_lcp[i];
116 }
117
118 template <typename archive_t>
119 void CEREAL_SAVE_FUNCTION_NAME(archive_t & ar) const
120 {
121 ar(CEREAL_NVP(m_lcp));
122 }
123
124 template <typename archive_t>
125 void CEREAL_LOAD_FUNCTION_NAME(archive_t & ar)
126 {
127 ar(CEREAL_NVP(m_lcp));
128 }
129
131 size_type serialize(std::ostream & out, structure_tree_node * v = nullptr, std::string name = "") const
132 {
133 structure_tree_node * child = structure_tree::add_child(v, name, util::class_name(*this));
134 size_type written_bytes = 0;
135 written_bytes += m_lcp.serialize(out, child, "lcp");
136 structure_tree::add_size(child, written_bytes);
137 return written_bytes;
138 }
139
141 bool operator==(lcp_bitcompressed const & other) const noexcept
142 {
143 return (m_lcp == other.m_lcp);
144 }
145
147 bool operator!=(lcp_bitcompressed const & other) const noexcept
148 {
149 return !(*this == other);
150 }
151
153 void load(std::istream & in)
154 {
155 m_lcp.load(in);
156 }
157};
158
159} // end namespace sdsl
160#endif
cereal.hpp offers cereal support
#define CEREAL_NVP(X)
Definition cereal.hpp:31
uint64_t size() const
Returns the number of elements currently stored.
uint8_t width() const
Returns the width of the integers which are accessed via the [] operator.
A generic vector class for integers of width .
bool empty() const noexcept
Equivalent to size() == 0.
int_vector_size_type size_type
void load(std::istream &in)
Load the int_vector for a stream.
size_type size() const noexcept
The number of elements in the int_vector.
int_vector_trait< t_width >::value_type value_type
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the int_vector to a stream.
static size_type max_size() noexcept
Maximum size of the int_vector.
const_iterator begin() const
Returns a const_iterator to the first element.
lcp_bitcompressed & operator=(lcp_bitcompressed &&)=default
size_type size() const
Number of elements in the instance.
bool empty() const
Returns if the data structure is empty.
lcp_bitcompressed()
Default Constructor.
static size_type max_size()
Returns the largest size that lcp_bitcompressed can ever have.
random_access_const_iterator< lcp_bitcompressed > const_iterator
value_type operator[](size_type i) const
Access operator.
const_iterator end() const
Returns a const_iterator to the element after the last element.
int_vector< t_width >::size_type size_type
lcp_bitcompressed(lcp_bitcompressed &&)=default
bool operator!=(lcp_bitcompressed const &other) const noexcept
Inequality operator.
int_vector< t_width >::value_type value_type
void load(std::istream &in)
Load from a stream.
bool operator==(lcp_bitcompressed const &other) const noexcept
Equality operator.
const value_type const_reference
lcp_bitcompressed(lcp_bitcompressed const &)=default
lcp_bitcompressed & operator=(lcp_bitcompressed const &)=default
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serialize to a stream.
void CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
void CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
lcp_bitcompressed(cache_config &config)
Constructor taking a cache_config.
Generic iterator for a random access container.
Definition iterators.hpp:24
static structure_tree_node * add_child(structure_tree_node *v, std::string const &name, std::string const &type)
static void add_size(structure_tree_node *v, uint64_t value)
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.
iterators.hpp contains an generic iterator for random access containers.
constexpr char KEY_LCP[]
Definition config.hpp:43
Namespace for the succinct data structure library.
std::string cache_file_name(std::string const &key, cache_config const &config)
Returns the file name of the resource.
Definition io.hpp:688
Contains declarations and definitions of data structure concepts.
Helper class for construction process.
Definition config.hpp:66
structure_tree.hpp contains a helper class which can represent the memory structure of a class.
util.hpp contains some helper methods for int_vector and other stuff like demangle class names.