Changed iter_new to inter_init and added new iter_new that allocates the iterator on the heap

This commit is contained in:
Leonardo committed 2019-05-08 11:47:00 -03:00
1 parent 6002650f06
commit c61ac2e347
29 files changed
+261 -71

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ int main(int argc, char const *argv[])
}
deque_iter iter;
d_iter_new(&iter, numbers);
d_iter_init(&iter, numbers);
size_t result, index, sum = 0;
+1 -1
View File
@@ -25,7 +25,7 @@ void print_set(set *s)
size_t index;
int result;
set_iter iter;
set_iter_new(&iter, s);
set_iter_init(&iter, s);
for (set_iter_tostart(&iter); !set_iter_end(&iter);)
{
set_iter_next(&iter, &result, &index);
+1 -1
View File
@@ -27,7 +27,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
deque_iter iter;
d_iter_new(&iter, d);
d_iter_init(&iter, d);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -43,7 +43,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
hmap_iter iter;
hm_iter_new(&iter, hm);
hm_iter_init(&iter, hm);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -42,7 +42,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
hset_iter iter;
hs_iter_new(&iter, hs);
hs_iter_init(&iter, hs);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -30,7 +30,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
heap_iter iter;
h_iter_new(&iter, h);
h_iter_init(&iter, h);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -25,7 +25,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
linked_iter iter;
ll_iter_new(&iter, ll);
ll_iter_init(&iter, ll);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -25,7 +25,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
list_iter iter;
l_iter_new(&iter, l);
l_iter_init(&iter, l);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -25,7 +25,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
queue_iter iter;
q_iter_new(&iter, q);
q_iter_init(&iter, q);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -25,7 +25,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
stack_iter iter;
s_iter_new(&iter, s);
s_iter_init(&iter, s);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -31,7 +31,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
tmap_iter iter;
tm_iter_new(&iter, tm);
tm_iter_init(&iter, tm);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -30,7 +30,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
tset_iter iter;
ts_iter_new(&iter, ts);
ts_iter_init(&iter, ts);
// Make the iterator go back and forward
for (int j = 0; j < 4; j++)
+1 -1
View File
@@ -24,7 +24,7 @@ int main(int argc, char const *argv[])
// Initialize iterator
linked_iter iter;
ll_iter_new(&iter, ll);
ll_iter_init(&iter, ll);
// Move cursor to the end of the list
ll_iter_toend(&iter);
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -77,7 +77,7 @@ int main(int argc, char const *argv[])
int key;
size_t mult, _;
for (tm_iter_new(&iter, map); !tm_iter_end(&iter); /* empty */)
for (tm_iter_init(&iter, map); !tm_iter_end(&iter); /* empty */)
{
// Map[key] = multiplicity
tm_iter_next(&iter, &key, &mult, &_);
+1 -1
View File
@@ -25,7 +25,7 @@ void print_set(set *s)
size_t index;
int result;
set_iter iter;
set_iter_new(&iter, s);
set_iter_init(&iter, s);
for (set_iter_tostart(&iter); !set_iter_end(&iter);)
{
set_iter_next(&iter, &result, &index);