本文整理汇总了C++中int_vector::setIntWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ int_vector::setIntWidth方法的具体用法?C++ int_vector::setIntWidth怎么用?C++ int_vector::setIntWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类int_vector
的用法示例。
在下文中一共展示了int_vector::setIntWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encode
bool ternary::encode(const int_vector &v, int_vector &z){
z.setIntWidth( v.getIntWidth() );
size_t z_bit_size = 0;
for(typename int_vector::const_iterator it = v.begin(), end = v.end(); it != end; ++it){
z_bit_size += encoding_length(*it);
}
z.bit_resize( z_bit_size ); // Initial size of z
if( z_bit_size & 0x3F ){ // if z_bit_size % 64 != 0
*(z.m_data + (z_bit_size>>6)) = 0; // initialize last word
}
示例2: index
/*!
* Constructor for building the Index
* \param[in] str C-string of the text
*/
index_bidirectional_waveletindex(const unsigned char* str) : index() {
size_t n = strlen((const char*)str);
int_vector<> sa(n+1, 0, bit_magic::l1BP(n+1)+1);
setText(str, n+1);
unsigned char *bwt = new unsigned char[n+1];
algorithm::calculate_sa(str, n+1, sa); // calculate the suffix array sa of str
{ /* Calculate Burrows-Wheeler-Transform */
size_t i = 0;
for(int_vector<>::const_iterator it = sa.begin(), end = sa.end(); it != end; ++it, ++i){
bwt[i] = m_char2comp[str[(*it+n)%(n+1)]];
}
}
backward_index = WaveletTree(bwt, n+1, m_sigma);
/* Construct the SA-Samples */
m_sa_sample.setIntWidth( bit_magic::l1BP(sa.size())+1 );
m_sa_sample.resize( (sa.size()+SampleDens-1)/SampleDens );
size_t idx=0;
size_t i=(sa.size()-1-SampleDens*(m_sa_sample.size()-1));
for(int_vector<>::const_iterator it = sa.begin()+(ptrdiff_t)i; i < sa.size(); it += (ptrdiff_t)SampleDens, i += SampleDens, ++idx){
m_sa_sample[idx] = *it;
}
unsigned char* reverse = new unsigned char[n+1];
for (size_t i=0; i<n; i++) reverse[i] = str[n-1-i];
reverse[n] = '\0';
algorithm::calculate_sa(reverse, n+1, sa); // calculate the suffix array sa of reverse string str
{ /* Calculate Burrows-Wheeler-Transform */
size_t i = 0;
for(int_vector<>::const_iterator it = sa.begin(), end = sa.end(); it != end; ++it, ++i){
bwt[i] = m_char2comp[reverse[(*it+n)%(n+1)]];
}
}
forward_index = WaveletTree(bwt, n+1, m_sigma);
delete [] bwt;
delete [] reverse;
}
示例3: index
/*!
* Constructor for building the Index
* \param[in] str C-string of the text
*/
index_csa_psi_text(const unsigned char *str) : index() {
size_t n = strlen((const char*)str);
int_vector<> sa(n+1, 0, bit_magic::l1BP(n+1)+1);
algorithm::calculate_sa(str, n+1, sa); // calculate the suffix array sa of str
int_vector<> m_psi;
sdsl::algorithm::sa2psi(sa, m_psi);
psi = EncVector(m_psi);
setText(str, n+1);
text = int_vector<>(sa.size(), 0, bit_magic::l1BP(sigma)+1);
for (size_t i=0; i<sa.size(); i++) text[i] = char2comp[str[i]];
/* Construct the SA-Samples */
m_sa_sample.setIntWidth( bit_magic::l1BP(sa.size())+1 );
m_sa_sample.resize( (sa.size()+SampleDens-1)/SampleDens );
size_t i=0, idx=0;
for(int_vector<>::const_iterator it = sa.begin(); i < sa.size(); it += (ptrdiff_t)SampleDens, i += SampleDens, ++idx) {
m_sa_sample[idx] = *it;
}
}