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; }
void DUncompressedProfile::ParseCO(uint8_t packetTypeIndication, data_t &data, data_iterator pos, data_t &output) { // pti is first byte of IP output.push_back(packetTypeIndication); // data contains the rest output.insert(output.end(), pos, data.end()); ++numberOfPacketsReceived; dataSizeCompressed += distance(pos, data.end()) + 1; dataSizeUncompressed += distance(pos, data.end()) + 1; }
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; }
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; }
void CTCPProfile::create_tcp_dynamic(const ROHC::tcphdr *tcp, data_t &output) { uint8_t ecn_ackStride_ackZero_urpZero_res = 0; // ecn_used if (tcp->ECE) { ecn_ackStride_ackZero_urpZero_res |= 0x80; } // ack_stride_flag // ack_zero if (tcp->ACK && tcp->ackNumber) { ecn_ackStride_ackZero_urpZero_res |= 0x20; } // urp_zero if (tcp->URG && tcp->urgPtr) { ecn_ackStride_ackZero_urpZero_res |= 0x10; } ecn_ackStride_ackZero_urpZero_res |= tcp->reserved; output.push_back(ecn_ackStride_ackZero_urpZero_res); AppendData(output, msn); AppendData(output, tcp->sequenceNumber); if (tcp->ACK && tcp->ackNumber) { AppendData(output, tcp->ackNumber); } AppendData(output, tcp->windowSize); AppendData(output, tcp->check); if (tcp->URG && tcp->urgPtr) { AppendData(output, tcp->urgPtr); } }
void push_back( int i ) { vec.push_back(i); }
void insert(int id, const Vector2D &pos) { m_verts.push_back(Elem(id, pos)); }