[libgee] Fix List.get API contract and fix implementations accordingly



commit cb7d173d1e4e410f4d702d2e6c1f809aa7fe061e
Author: Didier 'Ptitjes <ptitjes free fr>
Date:   Mon Sep 14 19:09:53 2009 +0200

    Fix List.get API contract and fix implementations accordingly

 gee/arraylist.vala  |    2 +-
 gee/linkedlist.vala |    9 +++------
 gee/list.vala       |    2 +-
 3 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/gee/arraylist.vala b/gee/arraylist.vala
index ccc59e9..1bbe2d2 100644
--- a/gee/arraylist.vala
+++ b/gee/arraylist.vala
@@ -95,7 +95,7 @@ public class Gee.ArrayList<G> : AbstractList<G> {
 	/**
 	 * @inheritDoc
 	 */
-	public override G? get (int index) {
+	public override G get (int index) {
 		assert (index >= 0);
 		assert (index < _size);
 
diff --git a/gee/linkedlist.vala b/gee/linkedlist.vala
index 802a278..2572fc5 100644
--- a/gee/linkedlist.vala
+++ b/gee/linkedlist.vala
@@ -121,16 +121,13 @@ public class Gee.LinkedList<G> : AbstractList<G>, Queue<G>, Deque<G> {
 	/**
 	 * @inheritDoc
 	 */
-	public override G? get (int index) {
+	public override G get (int index) {
 		assert (index >= 0);
 		assert (index < this._size);
 
 		unowned Node<G>? n = this._get_node_at (index);
-		if (n == null) {
-			return null;
-		} else {
-			return n.data;
-		}
+		assert (n != null);
+		return n.data;
 	}
 
 	/**
diff --git a/gee/list.vala b/gee/list.vala
index a692941..d3221bb 100644
--- a/gee/list.vala
+++ b/gee/list.vala
@@ -31,7 +31,7 @@ public interface Gee.List<G> : Collection<G> {
 	 *
 	 * @return      the item at the specified index in the list
 	 */
-	public abstract G? get (int index);
+	public abstract G get (int index);
 
 	/**
 	 * Sets the item at the specified index in this list.



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