[libgee/0.8] Remove use of explicit iterators



commit 576793e8299ed5b925aae440f10b9fc1a0368e88
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date:   Sun Sep 30 13:22:36 2012 +0200

    Remove use of explicit iterators

 gee/arraylist.vala  |    4 +---
 gee/linkedlist.vala |   12 ++++--------
 2 files changed, 5 insertions(+), 11 deletions(-)
---
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<G> : AbstractBidirList<G> {
 		}
 
 		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<G> : AbstractBidirList<G>, Queue<G>, Deque<G> {
 	 * { 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<G>? node = _head; node != null; node = node.next, idx++) {
+			if (this.equal_func (item, node.data)) {
+				return idx;
 			}
 		}
-		return result;
+		return -1;
 	}
 
 	/**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]