Repository: TheAlgorithms/C-Plus-Plus
File: strings/boyer_moore.cpp (C++)

Code before:

    int current_char = str.length();

    size_t border_index = str.length() + 1;

    border_pos[current_char] = border_index;

    while (current_char > 0) {
        while (border_index <= str.length() &&
               str[current_char - 1] != str[border_index - 1]) {
            if (arg[border_index] == 0)
                arg[border_index] = border_index - current_char;

            border_index = border_pos[border_index];
        }

        current_char--;
        border_index--;
        border_pos[current_char] = border_index;
    }

    size_t largest_border_index = border_pos[0];

    for (size_t i = 0; i < str.size(); i++) {
        if (arg[i] == 0)
            arg[i] = largest_border_index;

        // If we go pass the largest border we find the next one as we iterate
        if (i == largest_border_index)
            largest_border_index = border_pos[largest_border_index];
    }
}

/**
 * @brief A function that preprocess the bad char table
 * 
 * @param str The string being preprocessed
 * @param arg The bad char table
 * @return void
 */
void init_bad_char(const std::string& str, std::vector<size_t>& arg) {
    arg.resize(APLHABET_SIZE, str.length());

    for (size_t i = 0; i < str.length(); i++)
        arg[str[i]] = str.length() - i - 1;
}

/**
 * @brief A function that initializes pattern
 * 
 * @param str Text used for initialization

Review comment (suggestion):
```suggestion
/**
 * @namespace
 * @brief String algorithms
 */
namespace strings {
/**
 * @namespace
 * @brief Functions for the [Boyer Moore](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm) algorithm implementation
 */
namespace boyer_moore {
/**
```


Code after:
 * generated during the preprocessing of P.
 * @author [Stoycho Kyosev](https://github.com/stoychoX)
 */

#include <cassert>   /// for assert
#include <climits>   /// for CHAR_MAX macro
#include <cstring>   /// for strlen
#include <iostream>  /// for IO operations
#include <string>    /// for std::string
#include <vector>    /// for std::vector

#define APLHABET_SIZE CHAR_MAX  ///< number of symbols in the alphabet we use

/**
 * @namespace
 * @brief String algorithms
 */
namespace strings {
/**
 * @namespace
 * @brief Functions for the [Boyer
 * Moore](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm)
 * algorithm implementation
 */
namespace boyer_moore {
/**
 * @brief A structure representing all the data we need to search the
 * preprocessed pattern in text.
 */
struct pattern {
    std::string pat;

    std::vector<size_t>
        bad_char;  ///< bad char table used in [Bad Character
                   ///< Heuristic](https://www.geeksforgeeks.org/boyer-moore-algorithm-for-pattern-searching/)

    std::vector<size_t>
        good_suffix;  ///< good suffix table used for [Good Suffix
                      ///< heuristic](https://www.geeksforgeeks.org/boyer-moore-algorithm-good-suffix-heuristic/?ref=rp)
};

/**
 * @brief A function that preprocess the good suffix thable
 *
 * @param str The string being preprocessed
 * @param arg The good suffix table
 * @returns void
 */
void init_good_suffix(const std::string& str, std::vector<size_t>& arg) {
    arg.resize(str.size() + 1, 0);