当前位置: 首页>>代码示例>>C++>>正文


C++ data_t::size方法代码示例

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


在下文中一共展示了data_t::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: exception_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

示例5: 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

示例6: variation

double variation(data_t &dataset, size_t split){
	data_t::iterator i;
	double mean = 0;
	double variation = 0;
	for (i = dataset.begin(); i != dataset.end(); i++){
		mean += i->at(split);
	}
	mean /= dataset.size();
	for (i = dataset.begin(); i != dataset.end(); i++){
		variation += pow(i->at(split) - mean, 2.0);
	}
	variation /= dataset.size();
	return variation;
}
开发者ID:ssxiexiao,项目名称:kd-tree,代码行数:14,代码来源:kd-tree.cpp

示例7: 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

示例8: 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

示例9:

	file_offset_t bin_index_t::file_node::append_data(const data_t& res)
	{
		open_data_file();
		file_offset_t ret=fd->append(res);
		data_size=ret+res.size();
		return ret;
	}
开发者ID:JerryStreith,项目名称:five-in-line,代码行数:7,代码来源:bin_index.cpp

示例10:

    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

示例11: 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

示例12: runtime_error

	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

示例13: 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

示例14: CreateIR

    void CTCPProfile::CreateIR(const ROHC::iphdr *ip, const ROHC::tcphdr *tcp, data_t &output) {
        size_t headerStartIdx = output.size();
        
        if (!largeCID && cid)
        {
            output.push_back(CreateShortCID(cid));
        }
        
        output.push_back(IRv2Packet);
        
        if (largeCID)
        {
            SDVLEncode(back_inserter(output), cid);
        }
        
        output.push_back(static_cast<uint8_t>(ProfileID()));
        
        size_t crcPos = output.size();
        
        // Add zero crc for now
        output.push_back(0);
        
        create_ipv4_static(ip, output);
        
        create_tcp_static(tcp, output);
        
        create_ipv4_regular_innermost_dynamic(ip, output);
        
        //create_tcp_dynamic(msn, reorder_ratio, udp, output);
        
        // Calculate CRC
        uint8_t crc = CRC8(output.begin() + headerStartIdx, output.end());
        output[crcPos] = crc;
        
		IncreasePacketCount(PT_IR);
        
        ++numberOfIRPacketsSent;
        ++numberOfIRPacketsSinceReset;
    }
开发者ID:Columbitech,项目名称:rohc,代码行数:39,代码来源:ctcp_profile.cpp

示例15:

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

        size_t byteCount = data.size();
        size_t colCount = data[0];
        size_t rowCount = data[1];

        if (data.size() < 2+TH_0x00::dataByteCount || colCount < 1 || rowCount < 1 || colCount > 255 || rowCount > 255
            || ((byteCount - 2) % TH_0x00::dataByteCount != 0) || (colCount*rowCount != (byteCount - 2) / TH_0x00::dataByteCount))
        {
            std::cerr << "Invalid data array. Needs to contain 1+1+" << TH_0x00::dataByteCount << "*n bytes" << std::endl;
            return "";
        }

        string str = "[";

        for (uint i = 2, num = 0; i < byteCount; i += TH_0x00::dataByteCount, num++)
        {
            if (num % colCount == 0) // first column
            {
                str += "[";
            }
            str += TH_0x00::makeStringFromData(data_t(data.begin()+i, data.begin()+i+TH_0x00::dataByteCount));
            if (num % colCount < colCount - 1) // not last column
            {
                str += ",";
            } else {
                str += "]";
            }
        }

        str += "]";

        // TODO: prettified option
        
        return str;
    }
开发者ID:alberthdev,项目名称:CEmu,代码行数:38,代码来源:TH_0x02.cpp


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