Changed iter_new to inter_init and added new iter_new that allocates the iterator on the heap
This commit is contained in:
1 parent
6002650f06
commit
c61ac2e347
29 files changed
+261
-71
No files matched your search
@@ -54,7 +54,7 @@ int main(int argc, char const *argv[])
|
||||
|
||||
// Iterate over each element starting from the start (iter_new positions
|
||||
// the iterator to the start of the list) until the end of the list.
|
||||
for (l_iter_new(&iter, my_list); !l_iter_end(&iter);)
|
||||
for (l_iter_init(&iter, my_list); !l_iter_end(&iter);)
|
||||
{
|
||||
// Here index corresponds to the position of the result relative to all
|
||||
// other elements in the iteration. It is only a coincidence that the
|
||||
|
||||
@@ -53,7 +53,7 @@ int main(int argc, char const *argv[])
|
||||
|
||||
// Iterate through each letter and print it
|
||||
string_iter iter;
|
||||
str_iter_new(&iter, my_str);
|
||||
str_iter_init(&iter, my_str);
|
||||
size_t index;
|
||||
char result;
|
||||
|
||||
@@ -106,13 +106,13 @@ int main(int argc, char const *argv[])
|
||||
// Pop white space
|
||||
str_pop_front(str_out);
|
||||
|
||||
for (str_iter_new(&iter, my_str); !str_iter_end(&iter);)
|
||||
for (str_iter_init(&iter, my_str); !str_iter_end(&iter);)
|
||||
{
|
||||
str_iter_next(&iter, &result, &index);
|
||||
putchar(result);
|
||||
}
|
||||
printf("\nString length: %lu\n\n", str_count(my_str));
|
||||
for (str_iter_new(&iter, str_out); !str_iter_end(&iter);)
|
||||
for (str_iter_init(&iter, str_out); !str_iter_end(&iter);)
|
||||
{
|
||||
str_iter_next(&iter, &result, &index);
|
||||
putchar(result);
|
||||
|
||||
Reference in new issue
Block a user