diff --git a/d3/db2/boyer__moore_8cpp.html b/d3/db2/boyer__moore_8cpp.html index 5fb059117..e66906459 100644 --- a/d3/db2/boyer__moore_8cpp.html +++ b/d3/db2/boyer__moore_8cpp.html @@ -221,19 +221,19 @@ Functions
Returns
void
-
218 {
-
219 strings::boyer_moore::pattern ands;
-
220 strings::boyer_moore::init_pattern("and", ands);
-
221 std::vector<size_t> indexes = strings::boyer_moore::search(text, ands);
-
222
-
223 assert(indexes.size() == 2);
-
224 assert(strings::boyer_moore::is_prefix(text + indexes[0], "and", 3));
-
225 assert(strings::boyer_moore::is_prefix(text + indexes[1], "and", 3));
-
226}
-
void init_pattern(const std::string &str, pattern &arg)
A function that initializes pattern.
Definition boyer_moore.cpp:151
-
std::vector< size_t > search(const std::string &str, const pattern &arg)
A function that implements Boyer-Moore's algorithm.
Definition boyer_moore.cpp:163
+
220 {
+ + + +
224
+
225 assert(indexes.size() == 2);
+
226 assert(strings::boyer_moore::is_prefix(text + indexes[0], "and", 3));
+
227 assert(strings::boyer_moore::is_prefix(text + indexes[1], "and", 3));
+
228}
+
void init_pattern(const std::string &str, pattern &arg)
A function that initializes pattern.
Definition boyer_moore.cpp:153
+
std::vector< size_t > search(const std::string &str, const pattern &arg)
A function that implements Boyer-Moore's algorithm.
Definition boyer_moore.cpp:165
T size(T... args)
-
A structure representing all the data we need to search the preprocessed pattern in text.
Definition boyer_moore.cpp:68
+
A structure representing all the data we need to search the preprocessed pattern in text.
Definition boyer_moore.cpp:70
Here is the call graph for this function:
@@ -278,14 +278,14 @@ Here is the call graph for this function:
Returns
void
-
136 {
-
137 arg.resize(APLHABET_SIZE, str.length());
-
138
-
139 for (size_t i = 0; i < str.length(); i++) {
-
140 arg[str[i]] = str.length() - i - 1;
-
141 }
-
142}
-
#define APLHABET_SIZE
number of symbols in the alphabet we use
Definition boyer_moore.cpp:50
+
138 {
+
139 arg.resize(APLHABET_SIZE, str.length());
+
140
+
141 for (size_t i = 0; i < str.length(); i++) {
+
142 arg[str[i]] = str.length() - i - 1;
+
143 }
+
144}
+
#define APLHABET_SIZE
number of symbols in the alphabet we use
Definition boyer_moore.cpp:52
T resize(T... args)
Here is the call graph for this function:
@@ -330,47 +330,47 @@ Here is the call graph for this function:
Returns
void
-
87 {
-
88 arg.resize(str.size() + 1, 0);
-
89
-
90 // border_pos[i] - the index of the longest proper suffix of str[i..] which
-
91 // is also a proper prefix.
-
92 std::vector<size_t> border_pos(str.size() + 1, 0);
-
93
-
94 size_t current_char = str.length();
+
89 {
+
90 arg.resize(str.size() + 1, 0);
+
91
+
92 // border_pos[i] - the index of the longest proper suffix of str[i..] which
+
93 // is also a proper prefix.
+
94 std::vector<size_t> border_pos(str.size() + 1, 0);
95
-
96 size_t border_index = str.length() + 1;
+
96 size_t current_char = str.length();
97
-
98 border_pos[current_char] = border_index;
+
98 size_t border_index = str.length() + 1;
99
-
100 while (current_char > 0) {
-
101 while (border_index <= str.length() &&
-
102 str[current_char - 1] != str[border_index - 1]) {
-
103 if (arg[border_index] == 0) {
-
104 arg[border_index] = border_index - current_char;
-
105 }
-
106
-
107 border_index = border_pos[border_index];
-
108 }
-
109
-
110 current_char--;
-
111 border_index--;
-
112 border_pos[current_char] = border_index;
-
113 }
-
114
-
115 size_t largest_border_index = border_pos[0];
+
100 border_pos[current_char] = border_index;
+
101
+
102 while (current_char > 0) {
+
103 while (border_index <= str.length() &&
+
104 str[current_char - 1] != str[border_index - 1]) {
+
105 if (arg[border_index] == 0) {
+
106 arg[border_index] = border_index - current_char;
+
107 }
+
108
+
109 border_index = border_pos[border_index];
+
110 }
+
111
+
112 current_char--;
+
113 border_index--;
+
114 border_pos[current_char] = border_index;
+
115 }
116
-
117 for (size_t i = 0; i < str.size(); i++) {
-
118 if (arg[i] == 0) {
-
119 arg[i] = largest_border_index;
-
120 }
-
121
-
122 // If we go pass the largest border we find the next one as we iterate
-
123 if (i == largest_border_index) {
-
124 largest_border_index = border_pos[largest_border_index];
-
125 }
-
126 }
-
127}
+
117 size_t largest_border_index = border_pos[0];
+
118
+
119 for (size_t i = 0; i < str.size(); i++) {
+
120 if (arg[i] == 0) {
+
121 arg[i] = largest_border_index;
+
122 }
+
123
+
124 // If we go pass the largest border we find the next one as we iterate
+
125 if (i == largest_border_index) {
+
126 largest_border_index = border_pos[largest_border_index];
+
127 }
+
128 }
+
129}
Here is the call graph for this function:
@@ -414,13 +414,13 @@ Here is the call graph for this function:
Returns
void
-
151 {
-
152 arg.pat = str;
-
153 init_bad_char(str, arg.bad_char);
-
154 init_good_suffix(str, arg.good_suffix);
-
155}
-
void init_bad_char(const std::string &str, std::vector< size_t > &arg)
A function that preprocess the bad char table.
Definition boyer_moore.cpp:136
-
void init_good_suffix(const std::string &str, std::vector< size_t > &arg)
A function that preprocess the good suffix thable.
Definition boyer_moore.cpp:87
+
153 {
+
154 arg.pat = str;
+
155 init_bad_char(str, arg.bad_char);
+
156 init_good_suffix(str, arg.good_suffix);
+
157}
+
void init_bad_char(const std::string &str, std::vector< size_t > &arg)
A function that preprocess the bad char table.
Definition boyer_moore.cpp:138
+
void init_good_suffix(const std::string &str, std::vector< size_t > &arg)
A function that preprocess the good suffix thable.
Definition boyer_moore.cpp:89
Here is the call graph for this function:
@@ -473,19 +473,19 @@ Here is the call graph for this function:
Returns
true if pat IS prefix of str.
false if pat is NOT a prefix of str.
-
198 {
-
199 if (strlen(str) < len) {
-
200 return false;
-
201 }
-
202
-
203 for (size_t i = 0; i < len; i++) {
-
204 if (str[i] != pat[i]) {
-
205 return false;
-
206 }
-
207 }
-
208
-
209 return true;
-
210}
+
200 {
+
201 if (strlen(str) < len) {
+
202 return false;
+
203 }
+
204
+
205 for (size_t i = 0; i < len; i++) {
+
206 if (str[i] != pat[i]) {
+
207 return false;
+
208 }
+
209 }
+
210
+
211 return true;
+
212}
T strlen(T... args)
Here is the call graph for this function:
@@ -513,11 +513,11 @@ Here is the call graph for this function:

Main function.

Returns
0 on exit
-
267 {
-
268 tests(); // run self-test implementations
-
269 return 0;
-
270}
-
static void tests()
Self-test implementations.
Definition boyer_moore.cpp:248
+
269 {
+
270 tests(); // run self-test implementations
+
271 return 0;
+
272}
+
static void tests()
Self-test implementations.
Definition boyer_moore.cpp:250
Here is the call graph for this function:
@@ -550,17 +550,17 @@ Here is the call graph for this function:
Returns
void
-
233 {
- - - -
237
-
238 assert(indexes.size() == 6);
+
235 {
+ + +
239
-
240 for (const auto& currentIndex : indexes) {
-
241 assert(strings::boyer_moore::is_prefix(text + currentIndex, "pat", 3));
-
242 }
-
243}
+
240 assert(indexes.size() == 6);
+
241
+
242 for (const auto& currentIndex : indexes) {
+
243 assert(strings::boyer_moore::is_prefix(text + currentIndex, "pat", 3));
+
244 }
+
245}
Here is the call graph for this function:
@@ -604,31 +604,31 @@ Here is the call graph for this function:
Returns
Vector of indexes of the occurrences of pattern in text
-
163 {
-
164 size_t index_position = arg.pat.size() - 1;
-
165 std::vector<size_t> index_storage;
-
166
-
167 while (index_position < str.length()) {
-
168 size_t index_string = index_position;
-
169 int index_pattern = static_cast<int>(arg.pat.size()) - 1;
-
170
-
171 while (index_pattern >= 0 &&
-
172 str[index_string] == arg.pat[index_pattern]) {
-
173 --index_pattern;
-
174 --index_string;
-
175 }
-
176
-
177 if (index_pattern < 0) {
-
178 index_storage.push_back(index_position - arg.pat.length() + 1);
-
179 index_position += arg.good_suffix[0];
-
180 } else {
-
181 index_position += std::max(arg.bad_char[str[index_string]],
-
182 arg.good_suffix[index_pattern + 1]);
-
183 }
-
184 }
-
185
-
186 return index_storage;
-
187}
+
165 {
+
166 size_t index_position = arg.pat.size() - 1;
+
167 std::vector<size_t> index_storage;
+
168
+
169 while (index_position < str.length()) {
+
170 size_t index_string = index_position;
+
171 int index_pattern = static_cast<int>(arg.pat.size()) - 1;
+
172
+
173 while (index_pattern >= 0 &&
+
174 str[index_string] == arg.pat[index_pattern]) {
+
175 --index_pattern;
+
176 --index_string;
+
177 }
+
178
+
179 if (index_pattern < 0) {
+
180 index_storage.push_back(index_position - arg.pat.length() + 1);
+
181 index_position += arg.good_suffix[0];
+
182 } else {
+
183 index_position += std::max(arg.bad_char[str[index_string]],
+
184 arg.good_suffix[index_pattern + 1]);
+
185 }
+
186 }
+
187
+
188 return index_storage;
+
189}
T max(T... args)
T push_back(T... args)
@@ -664,23 +664,23 @@ Here is the call graph for this function:

Self-test implementations.

Returns
void
-
248 {
-
249 const char* text =
-
250 "When pat Mr. and Mrs. pat Dursley woke up on the dull, gray \
-
251 Tuesday our story starts, \
-
252 there was nothing about pat the cloudy sky outside to pat suggest that\
-
253 strange and \
-
254 mysterious things would pat soon be happening all pat over the \
-
255 country.";
-
256
-
257 and_test(text);
-
258 pat_test(text);
-
259
-
260 std::cout << "All tests have successfully passed!\n";
-
261}
+
250 {
+
251 const char* text =
+
252 "When pat Mr. and Mrs. pat Dursley woke up on the dull, gray \
+
253 Tuesday our story starts, \
+
254 there was nothing about pat the cloudy sky outside to pat suggest that\
+
255 strange and \
+
256 mysterious things would pat soon be happening all pat over the \
+
257 country.";
+
258
+
259 and_test(text);
+
260 pat_test(text);
+
261
+
262 std::cout << "All tests have successfully passed!\n";
+
263}
-
void pat_test(const char *text)
A test case in which we search for every appearance of the word 'pat'.
Definition boyer_moore.cpp:233
-
void and_test(const char *text)
A test case in which we search for every appearance of the word 'and'.
Definition boyer_moore.cpp:218
+
void pat_test(const char *text)
A test case in which we search for every appearance of the word 'pat'.
Definition boyer_moore.cpp:235
+
void and_test(const char *text)
A test case in which we search for every appearance of the word 'and'.
Definition boyer_moore.cpp:220
Here is the call graph for this function:
diff --git a/d8/ddf/sieve__of__eratosthenes_8cpp.html b/d8/ddf/sieve__of__eratosthenes_8cpp.html index 27ea8303a..e098f857f 100644 --- a/d8/ddf/sieve__of__eratosthenes_8cpp.html +++ b/d8/ddf/sieve__of__eratosthenes_8cpp.html @@ -157,7 +157,7 @@ Space Complexity : \(O(N)\)

71 return 0;
72}
constexpr uint32_t N
A struct to represent sparse table for min() as their invariant function, for the given array A....
Definition sparse_table.cpp:47
-
bool is_prime(int64_t num)
Function to check if the given number is prime or not.
Definition check_prime.cpp:30
+
bool is_prime(int64_t num)
Function to check if the given number is prime or not.
Definition check_prime.cpp:31
std::vector< bool > sieve(uint32_t N)
Definition sieve_of_eratosthenes.cpp:26
void tests()
Definition sieve_of_eratosthenes.cpp:56
diff --git a/db/d93/check__prime_8cpp.html b/db/d93/check__prime_8cpp.html index bfc79ccea..b9889f807 100644 --- a/db/d93/check__prime_8cpp.html +++ b/db/d93/check__prime_8cpp.html @@ -156,11 +156,11 @@ Functions

Main function.

Returns
0 on exit
-
80 {
-
81 tests(); // perform self-tests implementations
-
82 return 0;
-
83}
-
static void tests()
Self-test implementations.
Definition check_prime.cpp:61
+
81 {
+
82 tests(); // perform self-tests implementations
+
83 return 0;
+
84}
+
static void tests()
Self-test implementations.
Definition check_prime.cpp:62
Here is the call graph for this function:
@@ -194,23 +194,23 @@ Here is the call graph for this function:

Self-test implementations.

Returns
void
-
61 {
-
62 assert(math::is_prime(1) == false);
-
63 assert(math::is_prime(2) == true);
-
64 assert(math::is_prime(3) == true);
-
65 assert(math::is_prime(4) == false);
-
66 assert(math::is_prime(-4) == false);
-
67 assert(math::is_prime(7) == true);
-
68 assert(math::is_prime(-7) == false);
-
69 assert(math::is_prime(19) == true);
-
70 assert(math::is_prime(50) == false);
-
71 assert(math::is_prime(115249) == true);
-
72
-
73 std::cout << "All tests have successfully passed!" << std::endl;
-
74}
+
62 {
+
63 assert(math::is_prime(1) == false);
+
64 assert(math::is_prime(2) == true);
+
65 assert(math::is_prime(3) == true);
+
66 assert(math::is_prime(4) == false);
+
67 assert(math::is_prime(-4) == false);
+
68 assert(math::is_prime(7) == true);
+
69 assert(math::is_prime(-7) == false);
+
70 assert(math::is_prime(19) == true);
+
71 assert(math::is_prime(50) == false);
+
72 assert(math::is_prime(115249) == true);
+
73
+
74 std::cout << "All tests have successfully passed!" << std::endl;
+
75}
T endl(T... args)
-
bool is_prime(int64_t num)
Function to check if the given number is prime or not.
Definition check_prime.cpp:30
+
bool is_prime(int64_t num)
Function to check if the given number is prime or not.
Definition check_prime.cpp:31
Here is the call graph for this function:
diff --git a/dd/d47/namespacemath.html b/dd/d47/namespacemath.html index eebfe2984..8487a0dfe 100644 --- a/dd/d47/namespacemath.html +++ b/dd/d47/namespacemath.html @@ -929,31 +929,31 @@ false if number is not a factorial
false if number is not a prime.

Reduce all possibilities of a number which cannot be prime with the first 3 if, else if conditionals. Example: Since no even number, except 2 can be a prime number and the next prime we find after our checks is 5, we will start the for loop with i = 5. then for each loop we increment i by +6 and check if i or i+2 is a factor of the number; if it's a factor then we will return false. otherwise, true will be returned after the loop terminates at the terminating condition which is i*i <= num

-
30 {
-
31 /*!
-
32 * Reduce all possibilities of a number which cannot be prime with the first
-
33 * 3 if, else if conditionals. Example: Since no even number, except 2 can
-
34 * be a prime number and the next prime we find after our checks is 5,
-
35 * we will start the for loop with i = 5. then for each loop we increment
-
36 * i by +6 and check if i or i+2 is a factor of the number; if it's a factor
-
37 * then we will return false. otherwise, true will be returned after the
-
38 * loop terminates at the terminating condition which is i*i <= num
-
39 */
-
40 if (num <= 1) {
-
41 return false;
-
42 } else if (num == 2 || num == 3) {
-
43 return true;
-
44 } else if (num % 2 == 0 || num % 3 == 0) {
-
45 return false;
-
46 } else {
-
47 for (int64_t i = 5; i * i <= num; i = i + 6) {
-
48 if (num % i == 0 || num % (i + 2) == 0) {
-
49 return false;
-
50 }
+
31 {
+
32 /*!
+
33 * Reduce all possibilities of a number which cannot be prime with the first
+
34 * 3 if, else if conditionals. Example: Since no even number, except 2 can
+
35 * be a prime number and the next prime we find after our checks is 5,
+
36 * we will start the for loop with i = 5. then for each loop we increment
+
37 * i by +6 and check if i or i+2 is a factor of the number; if it's a factor
+
38 * then we will return false. otherwise, true will be returned after the
+
39 * loop terminates at the terminating condition which is i*i <= num
+
40 */
+
41 if (num <= 1) {
+
42 return false;
+
43 } else if (num == 2 || num == 3) {
+
44 return true;
+
45 } else if (num % 2 == 0 || num % 3 == 0) {
+
46 return false;
+
47 } else {
+
48 for (int64_t i = 5; i * i <= num; i = i + 6) {
+
49 if (num % i == 0 || num % (i + 2) == 0) {
+
50 return false;
51 }
52 }
-
53 return true;
-
54 }
+
53 }
+
54 return true;
+
55}