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

C++ data_t类代码示例

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

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



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

示例1: send

void CMaquetteImpl::send(CPacketToSend& packet, bool wait /*= false*/)
{
	const data_t data = packet.encode();
	LOG4CPLUS_DEBUG(logger, "Sending " << CPacket::Type::toString(data[0]) << ": " << data.size() << " byte\n" << CUtils::dump(data).c_str());

	// Send message to the server
	// See https://casablanca.codeplex.com/wikipage?title=Web%20Socket&referringTitle=Documentation
	auto buf = std::make_shared<producer_consumer_buffer<byte>>();
	auto task = buf->putn_nocopy(data.data(), data.size())
		.then([=](size_t size) {
			websocket_outgoing_message msg;
			msg.set_binary_message(buf->create_istream(), size);
			pplx::task<void>task = m_client->send(msg);
			task.then([](pplx::task<void> t) {
				try {
					t.get();
				} catch(const websocket_exception& ex) {
					LOG4CPLUS_ERROR(logger, "websocket_callback_client::send() failed: " << ex.what());
				}
			});
			return task;
		});
		
	if(wait) task.wait();
	if(packet.type() != CPacket::Type::PINGREQ) {
		m_keepAliveTimer.restart();
	}
}
开发者ID:cozzyy2002,项目名称:CppRestSdk,代码行数:28,代码来源:MaquetteImpl.cpp


示例2: fibonacci

    static bool fibonacci(data_t const& args, data_t& into) {
        // unpack arguments
        if (args.size() != 2)
            return false;
        auto f = args[0], l = args[1];

        // iterate
        uint64_t gen0 = 0, gen1 = 1, next = gen0 + gen1;
        for(auto i = 0u; i <= l; ++i)
        {
            std::cout << "fibonacci(" << f << ", " << l << ") at i == " << i << ", next: " << next << "\n";
            switch(i) {
            case 0:
                if (i>=f) into.push_back(gen0);
                break;
            case 1:
                if (i>=f) into.push_back(gen1);
                break;
            default:
            {
                next = gen0 + gen1;
                if (i>=f) into.push_back(next);
                gen0 = gen1;
                gen1 = next;
                break;
            }
            }
        }

        std::cout << "fibonacci(" << f << ", " << l << ") result: " << karma::format_delimited(karma::auto_, ';', into) << "\n";
        // done
        return true;
    }
开发者ID:CCJY,项目名称:coliru,代码行数:33,代码来源:main.cpp


示例3: to_string

    string TH_0x01::makeStringFromData(const data_t& data, const options_t& options)
    {
        (void)options;

        string str;

        size_t byteCount = data.size();
        size_t numCount = (size_t) ((data[0] & 0xFF) + ((data[1] << 8) & 0xFF00));
        if (byteCount < 2+TH_0x00::dataByteCount || ((byteCount - 2) % TH_0x00::dataByteCount != 0)
            || (numCount != (size_t)((byteCount - 2) / TH_0x00::dataByteCount)) || numCount > 999)
        {
            std::cerr << "Invalid data array. Needs to contain 2+" + to_string(TH_0x00::dataByteCount) + "*n bytes" << endl;
            return "";
        }

        str = "{";

        for (size_t i = 2, num = 0; i < byteCount; i += TH_0x00::dataByteCount, num++)
        {
            str += TH_0x00::makeStringFromData(data_t(data.begin()+i, data.begin()+i+TH_0x00::dataByteCount));
            if (num < numCount - 1) // not last num
            {
                str += ',';
            }
        }

        str += "}";

        return str;
    }
开发者ID:alberthdev,项目名称:CEmu,代码行数:30,代码来源:TH_0x01.cpp


示例4: fun

// fold functor example
static bool fun(const char *& acc, const data_t& data, const store_t& store,
        pos_t begin, pos_t end, bool has_next) {
    if (data.empty())
        return true;
    acc = data.str(store);
    std::cout << begin << ":" << end << ":" << has_next << ":" << acc << "\n";
    return true;
}
开发者ID:x0id,项目名称:utxx,代码行数:9,代码来源:actrie_mmap_demo.cpp


示例5: fun

// fold functor example
static bool fun(const char *& acc, const data_t& data, const store_t& store,
        pos_t, bool) {
    if (data.empty())
        return true;
    acc = data.str(store);
    std::cout << acc << std::endl;
    return true;
}
开发者ID:x0id,项目名称:utxx,代码行数:9,代码来源:digit_trie_mmap_demo.cpp


示例6: random_forest_p

void random_forest_p(const data_t& train, const vec_data_t& test, preds_t& train_preds, vec_preds_t& test_preds, args_t& args) {
  int trees = args.trees;
  int numthreads=args.processors, i, x, t;
  int fk = args.kfeatures;
  if (numthreads > trees)
    numthreads = trees;
  trees = (trees / numthreads) * numthreads;

  int trees_per_thread = trees / numthreads;  
  thread** threads = new thread*[numthreads];

  vector< vec_preds_t > seg;
  vector< preds_t > train_seg;
  for (i=0; i < numthreads; i++) {
    vec_preds_t p;
    init_pred_vec(test, p);
    seg.push_back(p);

    preds_t tp;
    init_pred(train, tp);
    train_seg.push_back(tp);
  }
 
  for (i=0;i<numthreads;i++)
    threads[i] = new thread(bind(multiple_forest, trees_per_thread, cref(train), cref(test), ref(train_seg[i]), ref(seg[i]), ref(args)));
  
  for (i=0;i<numthreads;i++){
    threads[i]->join();
    delete threads[i];
  }
  fprintf(stderr, "done threading\n");
  delete[] threads;

  // congregate results of the threads
  for (i = 0; i < numthreads; i++)
    for (t = 0; t < test.size(); t++)
      for (int j = 0; j < test[t].size(); j++)
	test_preds[t][j] += seg[i][t][j];

  for (i = 0; i < numthreads; i++)
      for (int j = 0; j < train.size(); j++)
	train_preds[j] += train_seg[i][j];

  // average results of the trees
  for (i = 0; i < test.size(); i++)
    for (int j = 0; j < test[i].size(); j++)
      test_preds[i][j] /= trees;

  for (int j = 0; j < train.size(); j++)
    train_preds[j] /= trees;

  // write results to file
  for (i = 0; i < test.size(); i++) {
    tuple::write_to_file(test_preds[i], test[i], args.test_outs[i]);
  }
}
开发者ID:atbrox,项目名称:rt_rank,代码行数:56,代码来源:forest.cpp


示例7: secure_session_t

    secure_session_t(const data_t& id, const data_t& priv_key, secure_session_callback_interface_t* callbacks):
      _session(NULL),
      _res(0){
      _callback.get_public_key_for_id=themispp::get_public_key_for_id_callback;
      _callback.send_data=themispp::send_callback;
      _callback.receive_data=themispp::receive_callback;
      _callback.state_changed=NULL;
      _callback.user_data=callbacks;
      _session=secure_session_create(&id[0], id.size(), &priv_key[0], priv_key.size(), &_callback);
      if(!_session)
	throw themispp::exception_t("Secure Session failde creating");
    }
开发者ID:Lagovas,项目名称:themis,代码行数:12,代码来源:secure_session.hpp


示例8: range

    static bool range(data_t const& args, data_t& into) {
        // unpack arguments
        if (args.size() != 2)
            return false;
        auto f = args[0], l = args[1];

        if (l>f)
            into.reserve(1 + l - f + into.size());
        for(; f<=l; ++f)
            into.push_back(f); // to optimize

        return true;
    }
开发者ID:CCJY,项目名称:coliru,代码行数:13,代码来源:main.cpp


示例9:

	bool bin_index_t::file_node::first(data_t& key,data_t& val) const
	{
		open_index_file();

		index_t ind;
		if(!first_item(root_page,ind))return false;

		key=ind.key;
		key.resize(key_len);
		val.resize(ind.data_len);
		load_data(ind.data_offset,val);
		return true;
	}
开发者ID:JerryStreith,项目名称:five-in-line,代码行数:13,代码来源:bin_index.cpp


示例10: validate_key_len

///////////////////////////////////////////////////////////////////////////////////
//  dir_node
//
	bool bin_index_t::dir_node::get(const data_t& key,data_t& val) const
	{
		validate_key_len(key);
		validate_index();
		
		data_t head(key.begin(),key.begin()+parent.dir_key_len);
		data_t tail(key.begin()+parent.dir_key_len,key.end());

		if(!std::binary_search(indexes.begin(),indexes.end(),head,data_less_pr()))
			return false;

		validate_sub(head);

		return sub_node->get(tail,val);
	}
开发者ID:JerryStreith,项目名称:five-in-line,代码行数:18,代码来源:bin_index.cpp


示例11: WARNING

/** Sets the filter. 
 * The length of the impulse response is arbitrary. It automatically
 * performs zero padding if necessary and creates the required number of 
 * partitions. It is not very efficient since it calls 
 * \b Convolver::prepare_impulse_response(). It is provided for convenience.
 * If you have the filter's transfer function in halfcomplex format use
 * \b Convolver::set_filter_f() instead. 
 * @param filter impulse response of the filter
 */
void Convolver::set_filter_t(const data_t& filter)
{

	if (filter.empty())
	{
		WARNING("You are trying to use an empty filter.");
		return;
	}

	data_t buffer;

	// TODO: It would be more efficient to use _fft_plan and _fft_buffer etc.
	prepare_impulse_response(buffer, &filter[0], filter.size(), _frame_size);

	set_filter_f(buffer);
}
开发者ID:flair2005,项目名称:avrs,代码行数:25,代码来源:convolver.cpp


示例12: clever_runner

void clever_runner(
        std::size_t thread_index,
        std::size_t iteration,
        atomic_count_t& counter,
        data_t& data)
{
    fill_data(data.at(thread_index));

    if (++counter == data_t::static_size) {
        compute_send_data(data);

        ++ iteration;
        if (iteration == 1000) {
            // exiting, because 1000 iterations are done
            tasks_processor::get().stop();
            return;
        }

        counter = 0;
        for (std::size_t i = 0; i < data_t::static_size; ++ i) {
            tasks_processor::get().push_task(boost::bind(
                clever_runner, 
                i,
                iteration, 
                boost::ref(counter), 
                boost::ref(data)
            ));
        }
    }
}
开发者ID:bonly,项目名称:exercise,代码行数:30,代码来源:20130120_barrier.cpp


示例13: invalid_argument

    string TH_0x20::makeStringFromData(const data_t& data, const options_t& options)
    {
        (void)options;

        if (data.size() != dataByteCount)
        {
            throw invalid_argument("Empty data array. Needs to contain " + to_string(dataByteCount) + " bytes");
        }

        string coeff = TH_0x00::makeStringFromData(data);

        string str = ((coeff != "0") ? (coeff + "*π") : "");

        // Improve final display
        str = regex_replace(str, regex("\\+1\\*"), "+");  str = regex_replace(str, regex("\\(1\\*"),  "(");
        str = regex_replace(str, regex("-1\\*"),   "-");  str = regex_replace(str, regex("\\(-1\\*"), "(-");
        str = regex_replace(str, regex("\\+-"),    "-");

        // Shouldn't happen - I don't believe the calc generate such files.
        if (str == "")
        {
            str = "0";
        }

        return str;
    }
开发者ID:adriweb,项目名称:tivars_lib_cpp,代码行数:26,代码来源:TH_0x20.cpp


示例14: validate_index

	bool bin_index_t::dir_node::first(data_t& key,data_t& val) const
	{
		validate_index();

		if(indexes.empty())return false;

		const data_t& head=indexes.front();
		validate_sub(head);

		data_t tail;
		if(!sub_node->first(tail,val))return false;
		
		key=head;
		key.insert(key.end(),tail.begin(),tail.end());

		return true;
	}
开发者ID:JerryStreith,项目名称:five-in-line,代码行数:17,代码来源:bin_index.cpp


示例15: invalid_argument

    string TH_0x1B::makeStringFromData(const data_t& data, const options_t& options)
    {
        (void)options;

        if (data.size() != dataByteCount)
        {
            throw invalid_argument("Empty data array. Needs to contain " + to_string(dataByteCount) + " bytes");
        }

        string coeffR = TH_0x00::makeStringFromData(data_t(data.begin(), data.begin() + TH_0x00::dataByteCount));
        string coeffI = TH_0x00::makeStringFromData(data_t(data.begin() + TH_0x00::dataByteCount, data.begin() + 2 * TH_0x00::dataByteCount));

        string str = dec2frac(atof(coeffR.c_str())) + "+" + dec2frac(atof(coeffI.c_str())) + "i";
        str = regex_replace(str, regex("\\+-"), "-");

        return str;
    }
开发者ID:adriweb,项目名称:tivars_lib_cpp,代码行数:17,代码来源:TH_0x1B.cpp


示例16: Compress

 void CTCPProfile::Compress(const data_t &data, data_t &output) {
     size_t outputInSize = output.size();
     const iphdr* ip = reinterpret_cast<const iphdr*>(&data[0]);
     const tcphdr* tcp = reinterpret_cast<const tcphdr*>(ip+ip->ihl*4);
     
     UpdateIpIdOffset(ip);
     
     if (IR_State == state)
     {
         CreateIR(ip, tcp, output);
     }
     else
     {
         CreateCO(ip, tcp, output);
     }
     
     UpdateIpInformation(ip);
     
     AdvanceState(false, false);
     increaseMsn();
     // Append payload
     // TODO, handle TCP options
     output.insert(output.end(), data.begin() + sizeof(iphdr) + sizeof(tcphdr), data.end());
     
     ++numberOfPacketsSent;
     dataSizeCompressed += output.size() - outputInSize;
     dataSizeUncompressed += data.size();
     
 }
开发者ID:Columbitech,项目名称:rohc,代码行数:29,代码来源:ctcp_profile.cpp


示例17: secure_comparator_t

 secure_comparator_t(const data_t& shared_secret)
     : comparator_(NULL)
 {
     if (shared_secret.empty()) {
         throw themispp::exception_t("Secure Comparator must have non-empty shared secret");
     }
     res_.reserve(512);
     comparator_ = secure_comparator_create();
     if (!comparator_) {
         throw themispp::exception_t("Secure Comparator construction failed");
     }
     themis_status_t status = secure_comparator_append_secret(comparator_,
                                                              &shared_secret[0],
                                                              shared_secret.size());
     if (THEMIS_SUCCESS != status) {
         throw themispp::exception_t("Secure Comparator failed to append secret", status);
     }
 }
开发者ID:cossacklabs,项目名称:themis,代码行数:18,代码来源:secure_comparator.hpp


示例18: makeStringFromData

    std::string STH_ExactFractionPi::makeStringFromData(const data_t& data, const options_t& options)
    {
        if (data.size() != 9)
        {
            throw std::invalid_argument("Invalid data array. Needs to contain 9 bytes");
        }

        return dec2frac(stod(STH_FP::makeStringFromData(data, options)), "π");
    }
开发者ID:zdimension,项目名称:CEmu,代码行数:9,代码来源:STH_ExactFractionPi.cpp


示例19: bin2points

	void bin2points(const data_t& bin,points_t& pts)
	{
		if((bin.size()%2)!=0)
			throw std::runtime_error("bin2points(): (bin.size()%2)!=0");

		pts.resize(bin.size()/2);

		for(unsigned i=0;i<pts.size();i++)
		{
			point& p=pts[i];

			char x=*reinterpret_cast<const unsigned char*>(&bin[i*2]);
			char y=*reinterpret_cast<const unsigned char*>(&bin[i*2+1]);

			p.x=x;
			p.y=y;
		}
	}
开发者ID:JerryStreith,项目名称:five-in-line,代码行数:18,代码来源:solution_tree_utils.cpp


示例20: construct

void construct(point &root, data_t dataset){
	if (dataset.size() == 0)
		return;
	root = new point_t();
	vector< double > buff;
	for (size_t i = 0; i < dataset.at(0).size(); i++){
		buff.push_back(variation(dataset, i));
	}
	size_t split = 0;
	double min;
	for (size_t i = 0; i < buff.size(); i++){
		if (i == 0){
			min = buff.at(i);
		}
		else{
			if (min < buff.at(i)){
				min = buff.at(i);
				split = i;
			}
		}
	}
	sort(dataset.begin(), dataset.end(), [split](vec_t a, vec_t b){ return a.at(split) < b.at(split); });
	size_t middle = dataset.size() / 2;
	root->split = split;
	for (size_t i = 0; i < dataset.at(middle).size(); i++){
		root->node.push_back(dataset.at(middle).at(i));
	}
	root->dim = root->node.size();
	data_t lDataset, rDataset;
	for (size_t i = 0; i < middle; i++){
		lDataset.push_back(dataset.at(i));
	}
	for (size_t i = middle + 1; i < dataset.size(); i++){
		rDataset.push_back(dataset.at(i));
	}
	construct(root->left, lDataset);
	construct(root->right, rDataset);
	if (root->left)
		root->left->parent = root;
	if (root->right)
		root->right->parent = root;
	return;
}
开发者ID:ssxiexiao,项目名称:kd-tree,代码行数:43,代码来源:kd-tree.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ data_type类代码示例发布时间:2022-05-31
下一篇:
C++ data_slice类代码示例发布时间: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