diff options
Diffstat (limited to 'misc/examples/list_erase.c')
| -rw-r--r-- | misc/examples/list_erase.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/misc/examples/list_erase.c b/misc/examples/list_erase.c index 47f56625..0201c2d9 100644 --- a/misc/examples/list_erase.c +++ b/misc/examples/list_erase.c @@ -7,23 +7,24 @@ int main () { - c_with (IList L = c_make(IList, {10, 20, 30, 40, 50}), IList_drop(&L)) - { - c_foreach (x, IList, L) - printf("%d ", *x.ref); - puts(""); - // 10 20 30 40 50 - IList_iter it = IList_begin(&L); // ^ - IList_next(&it); - it = IList_erase_at(&L, it); // 10 30 40 50 - // ^ - IList_iter end = IList_end(&L); // - IList_next(&it); - it = IList_erase_range(&L, it, end); // 10 30 - // ^ - printf("list contains:"); - c_foreach (x, IList, L) - printf(" %d", *x.ref); - puts(""); - } + IList L = c_make(IList, {10, 20, 30, 40, 50}); + + c_foreach (x, IList, L) + printf("%d ", *x.ref); + puts(""); + // 10 20 30 40 50 + IList_iter it = IList_begin(&L); // ^ + IList_next(&it); + it = IList_erase_at(&L, it); // 10 30 40 50 + // ^ + IList_iter end = IList_end(&L); // + IList_next(&it); + it = IList_erase_range(&L, it, end); // 10 30 + // ^ + printf("list contains:"); + c_foreach (x, IList, L) + printf(" %d", *x.ref); + puts(""); + + IList_drop(&L); } |
