MCPcopy Create free account
hub / github.com/davisking/dlib / split

Function split

dlib/string/string.h:929–971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

927 typename alloc
928 >
929 const std::vector<std::basic_string<charT,traits,alloc> > split (
930 const std::basic_string<charT,traits,alloc>& str,
931 const charT* delim = _dT(charT," \n\r\t")
932 )
933 {
934 std::basic_string<charT,traits,alloc> temp;
935
936 std::vector<std::basic_string<charT,traits,alloc> > res;
937
938 for (unsigned long i = 0; i < str.size(); ++i)
939 {
940 // check if delim contains the character str[i]
941 bool hit = false;
942 const charT* d = delim;
943 while (*d != '\0')
944 {
945 if (str[i] == *d)
946 {
947 hit = true;
948 break;
949 }
950 ++d;
951 }
952
953 if (hit)
954 {
955 if (temp.size() != 0)
956 {
957 res.push_back(temp);
958 temp.clear();
959 }
960 }
961 else
962 {
963 temp.push_back(str[i]);
964 }
965 }
966
967 if (temp.size() != 0)
968 res.push_back(temp);
969
970 return res;
971 }
972
973 template <
974 typename charT,

Callers 11

parse_annotation_fileFunction · 0.50
mainFunction · 0.50
test_splitFunction · 0.50
mexFunctionFunction · 0.50
match_endingsMethod · 0.50
splitMethod · 0.50
backwardMethod · 0.50
operator()Method · 0.50
make_training_examplesFunction · 0.50
mainFunction · 0.50

Calls 3

sizeMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45

Tested by 1

test_splitFunction · 0.40