本文整理汇总了C++中int_vector::width方法的典型用法代码示例。如果您正苦于以下问题:C++ int_vector::width方法的具体用法?C++ int_vector::width怎么用?C++ int_vector::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类int_vector
的用法示例。
在下文中一共展示了int_vector::width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encode
bool elias_delta::encode(const int_vector& v, int_vector& z)
{
typedef typename int_vector::size_type size_type;
z.width(v.width());
size_type z_bit_size = 0;
uint64_t w;
const uint64_t zero_val = v.width() < 64 ? (1ULL)<<v.width() : 0;
for (typename int_vector::const_iterator it = v.begin(), end = v.end(); it != end; ++it) {
if ((w=*it) == 0) {
w = zero_val;
}
z_bit_size += encoding_length(w);
}
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: calculate_sa
void calculate_sa(const unsigned char* c, typename int_vector<fixedIntWidth>::size_type len, int_vector<fixedIntWidth>& sa)
{
typedef typename int_vector<fixedIntWidth>::size_type size_type;
if (len <= 1) { // handle special case
sa = int_vector<fixedIntWidth>(len,0);
return;
}
bool small_file = (sizeof(len) <= 4 or len < 0x7FFFFFFFULL);
if (small_file) {
uint8_t oldIntWidth = sa.width();
if (32 == fixedIntWidth or (0==fixedIntWidth and 32 >= oldIntWidth)) {
sa.width(32);
sa.resize(len);
divsufsort(c, (int32_t*)sa.m_data, len);
// copy integers back to the right positions
if (oldIntWidth!=32) {
for (size_type i=0; i<len; ++i) {
sa.set_int(i*oldIntWidth, sa.get_int(i<<5, 32), oldIntWidth);
}
sa.width(oldIntWidth);
sa.resize(len);
}
} else {
if (sa.width() < bits::hi(len)+1) {
throw std::logic_error("width of int_vector is to small for the text!!!");
}
int_vector<> sufarray(len,0,32);
divsufsort(c, (int32_t*)sufarray.m_data, len);
for (size_type i=0; i<len; ++i) {
sa[i] = sufarray[i];
}
}
} else {
uint8_t oldIntWidth = sa.width();
sa.width(64);
sa.resize(len);
divsufsort64(c, (int64_t*)sa.m_data, len);
// copy integers back to the right positions
if (oldIntWidth!=64) {
for (size_type i=0; i<len; ++i) {
sa.set_int(i*oldIntWidth, sa.get_int(i<<6, 64), oldIntWidth);
}
sa.width(oldIntWidth);
sa.resize(len);
}
}
}