ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
MoveStructure.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File MoveStructure.h --------------------------*/
3/*--------------------------------------------------------------------------*/
49/*--------------------------------------------------------------------------*/
50/*----------------------------- DEFINITIONS --------------------------------*/
51/*--------------------------------------------------------------------------*/
52
53#ifndef __ADS_MoveStructure
54 #define __ADS_MoveStructure
55/* self-identification: #endif constant */
56
57/*--------------------------------------------------------------------------*/
58/*------------------------------ INCLUDES ----------------------------------*/
59/*--------------------------------------------------------------------------*/
60
61#include "ADS/Contract.h"
63
64#include <algorithm>
65#include <bit>
66#include <cstddef>
67#include <cstdint>
68#include <map>
69#include <span>
70#include <string_view>
71#include <utility>
72#include <vector>
73
74/*--------------------------------------------------------------------------*/
75/*--------------------------- NAMESPACE ------------------------------------*/
76/*--------------------------------------------------------------------------*/
77
78namespace ADS
79{
80
81/*--------------------------------------------------------------------------*/
82/*--------------------------- CLASS MoveStructure --------------------------*/
83/*--------------------------------------------------------------------------*/
84
88{
89
90/*--------------------------------------------------------------------------*/
91 public:
93 MoveStructure( void ) = default;
94
122 MoveStructure( std::span< const std::uint64_t > p ,
123 std::span< const std::uint64_t > q ,
124 std::span< const std::uint32_t > tag , std::uint64_t n );
125
127 [[nodiscard]] std::size_t intervals( void ) const { return( f_m ); }
128
130 [[nodiscard]] std::uint64_t size( void ) const { return( f_n ); }
131
134 [[nodiscard]] std::uint64_t start( std::size_t i ) const {
135 return( i == f_m ? f_n : f_P.get( i * std::size_t( f_wp ) , f_wp ) );
136 }
137
139 [[nodiscard]] std::uint32_t tag( std::size_t i ) const {
140 return( std::uint32_t( f_tag.get( i * std::size_t( f_wt ) , f_wt ) ) );
141 }
142
156 [[nodiscard]] std::pair< std::uint64_t , std::size_t >
157 move( std::uint64_t x , std::size_t i ) const;
158
162 [[nodiscard]] std::size_t interval( std::uint64_t x ) const;
163
166 [[nodiscard]] std::size_t sizeInBits( void ) const;
167
168/*----------------------------- THE PERSISTENCE ----------------------------*/
169
171 static constexpr std::string_view persistName = "MoveStructure";
172
175 template< class A >
176 void persist( A & a );
177
178/*--------------------------------------------------------------------------*/
179 private:
180 std::uint64_t f_n = 0;
181 std::size_t f_m = 0;
182 int f_wp = 1 , f_wd = 1 , f_wt = 1;
183 BitVector f_P;
184 BitVector f_Q;
185 BitVector f_D;
186 BitVector f_tag;
187
188 }; // end( class MoveStructure )
189
190/*--------------------------------------------------------------------------*/
191
192} // end( namespace ADS )
193
194/*--------------------------------------------------------------------------*/
195/*-------------------------- IMPLEMENTATION --------------------------------*/
196/*--------------------------------------------------------------------------*/
197
198#include "ADS/succinct/impl/MoveStructure.tpp"
199
200/*--------------------------------------------------------------------------*/
201
202#endif /* MoveStructure.h included */
203
204/*--------------------------------------------------------------------------*/
205/*------------------------ End File MoveStructure.h ------------------------*/
206/*--------------------------------------------------------------------------*/
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
std::uint32_t tag(std::size_t i) const
the tag of the interval
Definition MoveStructure.h:139
MoveStructure(void)=default
the permutation of no place
std::size_t sizeInBits(void) const
the bits of the starts, of the images, of their intervals and of the tags
MoveStructure(std::span< const std::uint64_t > p, std::span< const std::uint64_t > q, std::span< const std::uint32_t > tag, std::uint64_t n)
the permutation of the intervals that start at (sorted, the first at 0) onto those that start at ,...
std::size_t interval(std::uint64_t x) const
the interval of , by a binary search on the starts (for the first place of a walk)
std::uint64_t size(void) const
the number of places,
Definition MoveStructure.h:130
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition MoveStructure.h:171
std::pair< std::uint64_t, std::size_t > move(std::uint64_t x, std::size_t i) const
the image of , of the interval , and its interval
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
std::size_t intervals(void) const
the number of the intervals, after the balance
Definition MoveStructure.h:127
std::uint64_t start(std::size_t i) const
the start of the interval , for equal to intervals()
Definition MoveStructure.h:134
Definition ADT.h:96