19 #ifndef SCIRE_string_cstr_util_HPP
20 #define SCIRE_string_cstr_util_HPP
42 size_t len = strlen(str);
43 if (len > 128)
return false;
45 bool chrmap[128] = {
false};
48 if (chrmap[str[i]] ==
true)
50 chrmap[str[i]] =
true;
60 size_t len = strlen(str);
64 for (size_t i = 0; i < mid; i++) {
66 str[i] = str[end - i];
91 for (
i = 0;
i <
N;
i++) {
92 if (
map[
i] != 0)
return false;
106 size_t rep = strlen(replace);
109 while (subject[i] !=
'\0') {
110 if (subject[i] == search) {
111 for (size_t j = 0; j < rep; j++) {
112 result[len++] = replace[j];
115 result[len++] = subject[i];
123 template <
typename Type>
137 for (
int i =
len - 1;
i >= 0;
i--) {
155 char curc = subject[i];
157 while (subject[i] !=
'\0') {
158 if (subject[i+1] == curc) {
161 encstr[len++] = curc;
164 size_t nlen = NumToDecimalString(count, nstr);
165 for (size_t j = 0; j < nlen; j++) {
166 encstr[len++] = nstr[j];
169 curc = subject[i + 1];
187 size_t enclen = CharCountEncoding(subject, compstr);
188 if (enclen < strlen(subject))
192 while (subject[i] !=
'\0') {
193 compstr[i] = subject[i];
210 return StringMatchKMP<>::Position(
211 haystack + offset, strlen(haystack) - offset,
212 needle, strlen(needle));
218 const char* substring
221 size_t pos = StrPos(string, substring);
222 if (strlen(string) == pos)
233 size_t len = strlen(str);
234 if (strlen(rstr) != len)
return false;
236 size_t dublen = len * 2 + 1;
237 char* strstr =
new char[dublen];
239 strcat_s(strstr, dublen, str);
240 strcat_s(strstr, dublen, str);
static bool isRotation(const char *str, const char *rstr)
check if a string is a roation of another
static size_t CharCountCompress(const char subject[], char compstr[])
compress a string such that every repeated character is encoded as the character followed by count...
static size_t StrPos(const char *haystack, const char *needle, size_t offset=0)
Find the position of the first occurrence of a substring in a text.
static size_t Replace(const char subject[], char result[], char search, char replace[])
replace all occurrences of a character with some string
static size_t CharCountEncoding(const char subject[], char encstr[])
encode a string such that every repeated character is encoded as the character followed by count...
static bool isSubstring(const char *string, const char *substring)
check if a string is a substring of other
static size_t NumToDecimalString(Type num, char str[])
static bool IsPermutation(const char a[], const char b[])
check if a string passed is a permutation of the other
static void Reverse(char str[])
reverse the passed string
scire/graph/gale_shapley.hpp
static bool IsAllCharUnique(const char str[])
check if all characater in a string is unique