dev/vala/list_iterator/list_iterator.vala

20 lines
595 B
Vala

public void main () {
var list = new Gee.ArrayList<string> ();
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");
}