13 #ifndef MLPACK_CORE_DATA_TOKENIZERS_SPLIT_BY_ANY_OF_HPP
14 #define MLPACK_CORE_DATA_TOKENIZERS_SPLIT_BY_ANY_OF_HPP
17 #include <mlpack/core/boost_backport/boost_backport_string_view.hpp>
33 using MaskType = std::array<bool, 1 << CHAR_BIT>;
44 for (
char symbol : delimiters)
45 mask[
static_cast<unsigned char>(symbol)] =
true;
54 boost::string_view
operator()(boost::string_view& str)
const
56 boost::string_view retval;
58 while (retval.empty())
60 const std::size_t pos = FindFirstDelimiter(str);
67 retval = str.substr(0, pos);
68 str.remove_prefix(pos + 1);
96 size_t FindFirstDelimiter(
const boost::string_view str)
const
98 for (
size_t pos = 0; pos < str.size(); pos++)
100 if (mask[
static_cast<unsigned char>(str[pos])])