Iterator fixes and tests
This commit is contained in:
1 parent
af89885886
commit
9e8b7aa269
6 files changed
+47
-5
No files matched your search
+1
-1
@@ -381,7 +381,7 @@
|
||||
iter->cursor = target->head; \
|
||||
iter->index = 0; \
|
||||
iter->start = true; \
|
||||
iter->end = false; \
|
||||
iter->end = PFX##_empty(target); \
|
||||
} \
|
||||
\
|
||||
FMOD bool PFX##_iter_start(SNAME##_iter *iter) \
|
||||
|
||||
+1
-1
@@ -326,7 +326,7 @@
|
||||
iter->target = target; \
|
||||
iter->cursor = 0; \
|
||||
iter->start = true; \
|
||||
iter->end = false; \
|
||||
iter->end = PFX##_empty(target); \
|
||||
} \
|
||||
\
|
||||
FMOD bool PFX##_iter_start(SNAME##_iter *iter) \
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@
|
||||
iter->target = target; \
|
||||
iter->cursor = iter->target->count - 1; \
|
||||
iter->start = true; \
|
||||
iter->end = false; \
|
||||
iter->end = PFX##_empty(target); \
|
||||
} \
|
||||
\
|
||||
FMOD bool PFX##_iter_start(SNAME##_iter *iter) \
|
||||
|
||||
@@ -33,6 +33,20 @@ int main(int argc, char const *argv[])
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
for (ll_iter_tostart(&iter); !ll_iter_end(&iter); /**/)
|
||||
{
|
||||
ll_iter_next(&iter, &r, &i);
|
||||
printf("LL[%2d] = %2d\n", i, r);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
for (ll_iter_toend(&iter); !ll_iter_start(&iter); /**/)
|
||||
{
|
||||
ll_iter_prev(&iter, &r, &i);
|
||||
printf("LL[%2d] = %2d\n", i, r);
|
||||
}
|
||||
|
||||
ll_free(ll);
|
||||
|
||||
return 0;
|
||||
|
||||
+15
-1
@@ -1,5 +1,5 @@
|
||||
// Checks if the list iterator can go back and forward in the list without
|
||||
// hitting invalid states or a nul pointer. Check is done visually.
|
||||
// hitting invalid states or a null pointer. Check is done visually.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -33,6 +33,20 @@ int main(int argc, char const *argv[])
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
for (l_iter_tostart(&iter); !l_iter_end(&iter); /**/)
|
||||
{
|
||||
l_iter_next(&iter, &r, &i);
|
||||
printf("L[%2d] = %2d\n", i, r);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
for (l_iter_toend(&iter); !l_iter_start(&iter); /**/)
|
||||
{
|
||||
l_iter_prev(&iter, &r, &i);
|
||||
printf("L[%2d] = %2d\n", i, r);
|
||||
}
|
||||
|
||||
l_free(l);
|
||||
|
||||
return 0;
|
||||
|
||||
+15
-1
@@ -1,5 +1,5 @@
|
||||
// Checks if the stack iterator can go back and forward in the stack without
|
||||
// hitting invalid states or a nul pointer. Check is done visually.
|
||||
// hitting invalid states or a null pointer. Check is done visually.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -33,6 +33,20 @@ int main(int argc, char const *argv[])
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
for (s_iter_tostart(&iter); !s_iter_end(&iter); /**/)
|
||||
{
|
||||
s_iter_next(&iter, &r, &i);
|
||||
printf("S[%2d] = %2d\n", i, r);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
for (s_iter_toend(&iter); !s_iter_start(&iter); /**/)
|
||||
{
|
||||
s_iter_prev(&iter, &r, &i);
|
||||
printf("S[%2d] = %2d\n", i, r);
|
||||
}
|
||||
|
||||
s_free(s);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user