diff options
| author | Tyge Løvset <[email protected]> | 2023-04-08 22:37:06 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-08 22:37:06 +0200 |
| commit | 43120f2863a67db416ec3b379eb820e2704cafb7 (patch) | |
| tree | f3b9917940f94c1582bc39ea6f56b735295ec861 /misc/examples/list_erase.c | |
| parent | e8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff) | |
| parent | 6426ac05eb8c4dc1ab22aae2eb4139f9671981b7 (diff) | |
| download | STC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.tar.gz STC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.zip | |
Merge pull request #53 from tylov/dev42
Version 4.2 RC
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); } |
