From cb7d173d1e4e410f4d702d2e6c1f809aa7fe061e Mon Sep 17 00:00:00 2001 From: Didier 'Ptitjes Date: Mon, 14 Sep 2009 19:09:53 +0200 Subject: [PATCH] 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 : AbstractList { /** * @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 : AbstractList, Queue, Deque { /** * @inheritDoc */ - public override G? get (int index) { + public override G get (int index) { assert (index >= 0); assert (index < this._size); unowned Node? 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 : Collection { * * @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. -- 2.7.4