From 9c11aa58fe099be1804cc96b3b0e61a5a7258e53 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Sun, 27 Apr 2014 01:54:07 +0400 Subject: [PATCH] Vala: list_iterator added --- vala/list_iterator/list_iterator.vala | 19 +++++++++++++++++++ vala/list_iterator/run.sh | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 vala/list_iterator/list_iterator.vala create mode 100755 vala/list_iterator/run.sh diff --git a/vala/list_iterator/list_iterator.vala b/vala/list_iterator/list_iterator.vala new file mode 100644 index 0000000..b9b928e --- /dev/null +++ b/vala/list_iterator/list_iterator.vala @@ -0,0 +1,19 @@ +public void main () { + var list = new Gee.ArrayList (); + + list.add ("Kolan"); + list.add ("Inna"); + list.add ("Stalk"); + + print ("--- .foreach method ---\n"); + list.foreach ((elem) => { print (elem + "\n"); return true; }); + print ("--- foreach (var ---\n"); + foreach (var elem in list) print (elem + "\n"); + + //BAD (doesn't work): for (var it = list.bidir_list_iterator (); it.has_next (); it.next ()) + + print ("--- Internal iterator ---\n"); + var iter = list.bidir_list_iterator (); + for (var has_next = iter.first (); has_next; has_next = iter.next ()) + print (iter.get () + "\n"); +} diff --git a/vala/list_iterator/run.sh b/vala/list_iterator/run.sh new file mode 100755 index 0000000..1956414 --- /dev/null +++ b/vala/list_iterator/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +valac --Xcc='-w' --pkg=gee-0.8 list_iterator.vala && ./list_iterator