I have made two quite basic algorithms used for lossless data compression.This is my RLE:#include <string>std::string rle(const std::string& input) // encode (aaaaeecd -> 4a2e1c1d){    std::string output;    int n = input.size();    int i = 0;    while(i < n)    {        int run_count = 1;        int max_run_count = std::min(255, n - i); // condition: i + run_count < n, runcount <= 255        while(run_count < max_run_count && input[i + run_count] == input[i])            run_count++;        output += run_count; // run_count is between 0 and 255 (unsigned char)        output += input[i];        i += run_count;    }    return output;}std::string irle(const std::string& input) // decode (4a2e1c1d -> aaaaeecd){    std::string output;    for(int i = 0; i < input.size(); i += 2)    {        int nb = (int)(unsigned char)input[i]; // range between 0 and 255        for(int k = 0; k < nb; k++)            output += input[i+1];    }    return output;}and here goes my MTF:#include <string>#include <deque>#include <list>#include <algorithm>/*if alphabet A = {'a', 'b', 'c'}    then string accbc is encoded 02021    (a is at index 0, alphabet remains {'a', 'b', 'c'}, outputs 0 ;     c is at index 2, alphabet becomes {'c', 'a', 'b'}, outputs 2 ;     c is at index 0, alphabet remains {'c', 'a', 'b'}, outputs 0 ;     b is at index 2, alphabet becomes {'b', 'c', 'a'}, outputs 2 ;     a is at index 1, alphabet becomes {'a', 'b', 'c'}, outputs 1)*/std::string mtf(const std::string& input){    std::string output;    std::list<char> alphabet; // constant erase/insert    for(int i = 0; i <= 255; i++)        alphabet.push_back((char)i);    for(char c: input)    {        auto c_it = find(alphabet.begin(), alphabet.end(), c); // find char c in the alphabet        output += distance(alphabet.begin(), c_it); // output index of char c in the alphabet        // move character to the front of the alphabet        alphabet.erase(c_it);        alphabet.insert(alphabet.begin(), c);    }    return output;}/*reverse operation:    for each number, outputs the character at the corresponding index in the alphabet        then move this character to the front of the alphabet        and keep going*/std::string imtf(const std::string& input){    std::string output;    std::deque<char> alphabet; // constant erase (begin) & operator[] ; insert (middle) is O(n)    for(int i = 0; i <= 255; i++)        alphabet.push_back((char)i);    for(unsigned char n: input)    {        char temp_c = alphabet[n];        output += temp_c;        alphabet.erase(alphabet.begin() + n);        alphabet.insert(alphabet.begin(), temp_c);    }    return output;}I know there are many possible improvments possible, especially for the RLE algorithm. I would just like a review on the C++ syntax I've used, especially on the structures I have chosen.
Run Length Encoding (RLE) and Move To Front (MTF) in C++
c++;algorithm;compression