From: Maciej Piechotka Date: Sun, 30 Sep 2012 11:22:36 +0000 (+0200) Subject: Remove use of explicit iterators X-Git-Tag: 0.8.1~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=576793e8299ed5b925aae440f10b9fc1a0368e88;p=platform%2Fupstream%2Flibgee.git Remove use of explicit iterators --- diff --git a/gee/arraylist.vala b/gee/arraylist.vala index 5242afe..3312aff 100644 --- a/gee/arraylist.vala +++ b/gee/arraylist.vala @@ -243,9 +243,7 @@ public class Gee.ArrayList : AbstractBidirList { } grow_if_needed (collection.size); - foreach (G item in collection) { - _items[_size++] = item; - } + collection.foreach ((item) => {_items[_size++] = item; return true;}); _stamp++; return true; } diff --git a/gee/linkedlist.vala b/gee/linkedlist.vala index 4a5acd4..52e74c9 100644 --- a/gee/linkedlist.vala +++ b/gee/linkedlist.vala @@ -193,17 +193,13 @@ public class Gee.LinkedList : AbstractBidirList, Queue, Deque { * {@inheritDoc} */ public override int index_of (G item) { - int result = -1; int idx = 0; - foreach (G node_item in (Collection)this) { - if (this.equal_func (item, node_item)) { - result = idx; - break; - } else { - idx++; + for (weak Node? node = _head; node != null; node = node.next, idx++) { + if (this.equal_func (item, node.data)) { + return idx; } } - return result; + return -1; } /**