• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ int_vector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中int_vector的典型用法代码示例。如果您正苦于以下问题:C++ int_vector类的具体用法?C++ int_vector怎么用?C++ int_vector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了int_vector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: lcp_byte

        //! Constructor
        lcp_byte(cache_config& config) {
            std::string lcp_file = cache_file_name(conf::KEY_LCP, config);
            int_vector_buffer<> lcp_buf(lcp_file);
            m_small_lcp = int_vector<8>(lcp_buf.size());
            size_type l=0, max_l=0, max_big_idx=0, big_sum=0;

            for (size_type i=0; i < m_small_lcp.size(); ++i) {
                if ((l=lcp_buf[i]) < 255) {
                    m_small_lcp[i] = l;
                } else {
                    m_small_lcp[i] = 255;
                    if (l > max_l) max_l = l;
                    max_big_idx = i;
                    ++big_sum;
                }
            }
            m_big_lcp     = int_vector<>(big_sum, 0, bits::hi(max_l)+1);
            m_big_lcp_idx = int_vector<>(big_sum, 0, bits::hi(max_big_idx)+1);

            for (size_type i=0,ii=0; i<m_small_lcp.size(); ++i) {
                if ((l=lcp_buf[i]) >= 255) {
                    m_big_lcp[ii] = l;
                    m_big_lcp_idx[ii] = i;
                    ++ii;
                }
            }
        }
开发者ID:chenlonggang,项目名称:sdsl-lite,代码行数:28,代码来源:lcp_byte.hpp


示例2: queryImgIDKeywords

// query by keywords
std::vector<double> queryImgIDKeywords(const int dbId, long int id, int numres, int kwJoinType, int_vector keywords, bool colorOnly){
	if (!validate_dbid(dbId)) { cerr << "ERROR: database space not found (" << dbId << ")" << endl; return std::vector<double>();}

	if ((id != 0) && !validate_imgid(dbId, id)) { // not search random and image doesnt exist
		cerr << "ERROR: image id (" << id << ") not found on given dbid (" << dbId << ") or dbid not existant" << endl ;
		return std::vector<double>();
	}

	if (keywords.size() < 1) {
		cerr << "ERROR: At least one keyword must be supplied" << endl ;
		return std::vector<double>();
	}

	// populate filter
	intVectorIterator it = keywords.begin();
	bloom_filter* bf = 0;

    // OR or AND each kwd postings filter to get final filter
    // start with the first one
    bf = new bloom_filter(*(getKwdPostings(*it)->imgIdsFilter));
    it++;
    for (; it != keywords.end(); it++) { // iterate the rest
        if (kwJoinType) { // and'd
            (*bf) &= *(getKwdPostings(*it)->imgIdsFilter);
        } else { // or'd
            (*bf) |= *(getKwdPostings(*it)->imgIdsFilter);
        }
    }

	if (id == 0) { // random images with these kwds

		vector<double> V; // select all images with the desired keywords
		for (sigIterator sit = dbSpace[dbId]->sigs.begin(); sit != dbSpace[dbId]->sigs.end(); sit++) {
			if (V.size() > 20*numres) break;

			if ((bf == 0) || (bf->contains((*sit).first))) { // image has desired keyword or we're querying random
				V.insert(V.end(), (*sit).first);
				V.insert(V.end(), 0);
			}
		}

		vector<double> Vres;

		for (int var = 0; var < min(V.size()/2, numres); ) { // var goes from 0 to numres
			int rint = rand()%(V.size()/2);
			if (V[rint*2] > 0) { // havent added this random result yet
				Vres.insert(Vres.end(), V[rint*2] );
				Vres.insert(Vres.end(), 0 );
				V[rint*2] = 0;
				++var;
			}
			++var;
		}

		return Vres;
	}
	return queryImgIDFiltered(dbId, id, numres, bf, colorOnly);

}
开发者ID:jannson,项目名称:iskdaemon,代码行数:60,代码来源:imgdb.cpp


示例3: 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
	}
开发者ID:cpockrandt,项目名称:pr_dict_cmp,代码行数:10,代码来源:ternary_coder.hpp


示例4: build_vector

std::vector<int> const build_vector()
{
    typedef std::vector<int> int_vector;
    static int_vector data = init_vector();
    int_vector::size_type const size = data.size();
    int_vector::iterator it = data.begin();
    int_vector::iterator const end = data.end();
    for (; it != end; ++it)
        *it += size;
    return data;
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:11,代码来源:container_tests5b.cpp


示例5: index_sa_text_psi

		/*! 
		 * Constructor for building the Index
		 * \param[in] str C-string of the text
		 */
		index_sa_text_psi(const unsigned char* str) : index() {

			size_t n = strlen((const char*)str);
			sa = int_vector<>(n+1, 0, bit_magic::l1BP(n+1)+1);
			algorithm::calculate_sa(str, n+1, sa);   // calculate the suffix array sa of str
			sdsl::algorithm::sa2psi(sa, 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]];
		}
开发者ID:cpockrandt,项目名称:pr_dict_cmp,代码行数:15,代码来源:index_sa_text_psi.hpp


示例6: build_unordered_set

std::unordered_set<int> const build_unordered_set()
{
    typedef std::unordered_set<int> int_set;
    typedef std::vector<int> int_vector;

    int_set result;
    int_vector const data = build_vector();
    int_vector::const_iterator it = data.begin();
    int_vector::const_iterator const end = data.end();
    result.insert(it, end);
    return result;
}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:12,代码来源:container_tests12a.cpp


示例7: addKeywordsImg

bool addKeywordsImg(const int dbId, const int id, int_vector hashes){
	if (!validate_imgid(dbId, id)) { cerr << "ERROR: image id (" << id << ") not found on given dbid (" << dbId << ") or dbid not existant" << endl ; return false;};

	// populate keyword postings
	for (intVectorIterator it = hashes.begin(); it != hashes.end(); it++) {
		getKwdPostings(*it)->imgIdsFilter->insert(id);
	}

	// populate image kwds
	int_hashset& imgKwds = dbSpace[dbId]->sigs[id]->keywords;
	imgKwds.insert(hashes.begin(),hashes.end());
	return true;
}
开发者ID:jannson,项目名称:iskdaemon,代码行数:13,代码来源:imgdb.cpp


示例8: build_map

std::map<int, int> const build_map()
{
    typedef std::map<int, int> int_map;
    typedef std::vector<int> int_vector;

    int_map result;
    int_vector const data = build_vector();
    int_vector::const_iterator it = data.begin();
    int_vector::const_iterator const end = data.end();
    for (; it != end; ++it) {
	    int const value = *it;
	    result[value] = 100 * value;
    }
    return result;
}
开发者ID:AlexanderToifl,项目名称:viennamesh-dev,代码行数:15,代码来源:container_tests6b.cpp


示例9: index_bidirectional_waveletindex

		/*! 
		 * 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;

		}
开发者ID:cpockrandt,项目名称:pr_dict_cmp,代码行数:51,代码来源:index_bidirectional_waveletindex.hpp


示例10: lcp_bitcompressed

 //! Constructor taking a cache_config
 lcp_bitcompressed(cache_config& config) {
     std::string lcp_file = cache_file_name(conf::KEY_LCP, config);
     int_vector_buffer<> lcp_buf(lcp_file);
     m_lcp = int_vector<t_width>(lcp_buf.size(), 0, lcp_buf.width());
     for (size_type i=0; i < m_lcp.size(); ++i) {
         m_lcp[i] = lcp_buf[i];
     }
 }
开发者ID:Alienfeel,项目名称:sdsl-lite,代码行数:9,代码来源:lcp_bitcompressed.hpp


示例11: contains_no_zero_symbol

bool contains_no_zero_symbol(const int_vector& text, const std::string& file)
{
    for (int_vector_size_type i=0; i < text.size(); ++i) {
        if ((uint64_t)0 == text[i]) {
            throw std::logic_error(std::string("Error: File \"")+file+"\" contains zero symbol.");
            return false;
        }
    }
    return true;
}
开发者ID:XLPE,项目名称:sdsl-lite,代码行数:10,代码来源:construct.hpp


示例12: index_sa_text_occ

		/*! 
		 * Constructor for building the Index
		 * \param[in] str C-string of the text
		 */
		index_sa_text_occ(const unsigned char* str) : index() {

			size_t n = strlen((const char*)str);
			sa = int_vector<>(n+1, 0, bit_magic::l1BP(n+1)+1);
			algorithm::calculate_sa(str, n+1, sa);   // calculate the suffix array sa of str
			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]];

			unsigned char *bwt = new unsigned char[n+1];
			{ /* 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)]];
				}
			}
			occ = Occ(bwt, n+1, m_sigma);
			delete[] bwt;
		}
开发者ID:cpockrandt,项目名称:pr_dict_cmp,代码行数:24,代码来源:index_sa_text_occ.hpp


示例13: index_csa_psi_text

    /*!
     * 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;
        }
    }
开发者ID:cpockrandt,项目名称:pr_dict_cmp,代码行数:25,代码来源:index_csa_psi_text.hpp


示例14: load

 //! Load from a stream.
 void load(std::istream& in) {
     m_data.load(in);
     m_overflow.load(in);
     m_overflow_rank.load(in, &m_overflow);
     m_level_pointer_and_rank.load(in);
     read_member(m_max_level, in);
 }
开发者ID:chenlonggang,项目名称:sdsl-lite,代码行数:8,代码来源:lcp_dac.hpp


示例15: swap

        //! Swap operator
        void swap(wt_int_rlmn& wt) {
            if (this != &wt) {
                std::swap(m_size, wt.m_size);
                m_bl.swap(wt.m_bl);
                m_bf.swap(wt.m_bf);
                m_wt.swap(wt.m_wt);

                m_bl_rank.swap(wt.m_bl_rank);
                m_bl_rank.set_vector(&m_bl);
                wt.m_bl_rank.set_vector(&(wt.m_bl));
                m_bf_rank.swap(wt.m_bf_rank);
                m_bf_rank.set_vector(&m_bf);
                wt.m_bf_rank.set_vector(&(wt.m_bf));

                m_bl_select.swap(wt.m_bl_select);
                m_bl_select.set_vector(&m_bl);
                wt.m_bl_select.set_vector(&(wt.m_bl));
                m_bf_select.swap(wt.m_bf_select);
                m_bf_select.set_vector(&m_bf);
                wt.m_bf_select.set_vector(&(wt.m_bf));

                m_C.swap(wt.m_C);
                m_C_bf_rank.swap(wt.m_C_bf_rank);
            }
        }
开发者ID:tb37,项目名称:sdsl-lite,代码行数:26,代码来源:wt_int_rlmn.hpp


示例16: impl

 impl()
 {
     m_nr_to_bin.resize(1<<n);
     m_bin_to_nr.resize(1<<n);
     for (int i=0, cnt=0, class_cnt=0; i<=n; ++i) {
         m_C[i] = cnt;
         class_cnt = 0;
         std::vector<bool> b(n,0);
         for (int j=0; j<i; ++j) b[n-j-1] = 1;
         do {
             uint32_t x=0;
             for (int k=0; k<n; ++k)
                 x |= ((uint32_t)b[n-k-1])<<(n-1-k);
             m_nr_to_bin[cnt] = x;
             m_bin_to_nr[x] = class_cnt;
             ++cnt;
             ++class_cnt;
         } while (next_permutation(b.begin(), b.end()));
         if (class_cnt == 1)
             m_space_for_bt[i] = 0;
         else
             m_space_for_bt[i] = bits::hi(class_cnt)+1;
     }
     if (n == 15) {
         for (int x=0; x<256; ++x) {
             m_space_for_bt_pair[x] = m_space_for_bt[x>>4] + m_space_for_bt[x&0x0F];
         }
     }
 }
开发者ID:Tillyard,项目名称:sdsl-lite,代码行数:29,代码来源:rrr_vector_15.hpp


示例17: load

 //! Loads the data structure from the given istream.
 void load(std::istream& in) {
     read_member(m_size, in);
     m_bt.load(in);
     m_btnr.load(in);
     m_btnrp.load(in);
     m_rank.load(in);
     m_invert.load(in);
 }
开发者ID:Alienfeel,项目名称:sdsl-lite,代码行数:9,代码来源:rrr_vector.hpp


示例18: load

 /*! \param in In-Stream to load the rank_support data from.
  */
 void load(std::istream& in) {
     m_abs_samples.load(in);
     m_differences.load(in);
     read_member(m_ones, in);
     read_member(m_size, in);
     m_contains_abs_sample.load(in);
     m_rank_contains_abs_sample.load(in, &m_contains_abs_sample);
 }
开发者ID:Garonenur,项目名称:sdsl-lite,代码行数:10,代码来源:nearest_neighbour_dictionary.hpp


示例19: swap

        //! Swap method for lcp_dac
        void swap(lcp_dac& lcp_c) {
            m_data.swap(lcp_c.m_data);
            m_overflow.swap(lcp_c.m_overflow);
            util::swap_support(m_overflow_rank, lcp_c.m_overflow_rank,
                               &m_overflow, &(lcp_c.m_overflow));

            m_level_pointer_and_rank.swap(lcp_c.m_level_pointer_and_rank);
            std::swap(m_max_level, lcp_c.m_max_level);
        }
开发者ID:chenlonggang,项目名称:sdsl-lite,代码行数:10,代码来源:lcp_dac.hpp


示例20: swap

 //! Swap method
 void swap(rrr_vector& rrr) {
     if (this != &rrr) {
         std::swap(m_size, rrr.m_size);
         m_bt.swap(rrr.m_bt);
         m_btnr.swap(rrr.m_btnr);
         m_btnrp.swap(rrr.m_btnrp);
         m_rank.swap(rrr.m_rank);
         m_invert.swap(rrr.m_invert);
     }
 }
开发者ID:Alienfeel,项目名称:sdsl-lite,代码行数:11,代码来源:rrr_vector.hpp



注:本文中的int_vector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ intarray类代码示例发布时间:2022-05-31
下一篇:
C++ intVector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap