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


C++ data_t类代码示例

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


在下文中一共展示了data_t类的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: 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


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