Skip to content

Instantly share code, notes, and snippets.

Created January 21, 2021 18:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#include <vector>
#include <unordered_map>
#include <string>
#include <iostream>
struct PDU { char header; char c; };
std::vector<std::string> reorder(const std::vector<PDU> &pdus) {
std::unordered_map<int, std::string> words;
for (auto&& pdu: pdus) {
const char is_signal = pdu.header & 0x4;
if (is_signal) {
const int id = (pdu.header & 0xF0) >> 4;
std::string& w = words[id];
std::vector<std::string> result;
for (auto&& pair: words) {
return result;
int main() {
std::vector<PDU> test{{(char)0xA0, 'A'}, {(char)0xA4, 'L'}, {(char)0xB0, 'O'}, {(char)0xA0, 'L'}, {(char)0xA0, 'A'}};
auto words = reorder(test);
for (auto&& w: words) {
std::cout << w << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment