[libgee] Change ReadOnlyList to inherit from ReadOnlyCollection.
- From: Didier 'Ptitjes' Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgee] Change ReadOnlyList to inherit from ReadOnlyCollection.
- Date: Sun, 6 Sep 2009 23:08:58 +0000 (UTC)
commit 3d108d96583b6ce47c44c04338f2b425c6ad637a
Author: Tomaž Vajngerl <quikee gmail com>
Date: Mon Aug 3 22:10:48 2009 +0200
Change ReadOnlyList to inherit from ReadOnlyCollection.
Fixes part of bug 590677.
gee/readonlylist.vala | 143 ++++---------------------------------------------
1 files changed, 11 insertions(+), 132 deletions(-)
---
diff --git a/gee/readonlylist.vala b/gee/readonlylist.vala
index 23db056..7412bf8 100644
--- a/gee/readonlylist.vala
+++ b/gee/readonlylist.vala
@@ -31,93 +31,27 @@ using GLib;
*
* @see Gee.List
*/
-public class Gee.ReadOnlyList<G> : Object, Iterable<G>, Collection<G>, List<G> {
+public class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
/**
- * @inheritDoc
- */
- public int size {
- get { return _list.size; }
- }
-
- /**
- * @inheritDoc
- */
- public bool is_empty {
- get { return _list.is_empty; }
- }
-
- /**
- * The decorated list.
- */
- public List<G> list {
- construct { _list = value; }
- }
-
- private List<G> _list;
-
- /**
- * Constructs a read-only set that mirrors the content of the specified
+ * Constructs a read-only list that mirrors the content of the specified
* list.
*
* @param list the list to decorate (may be null).
*/
public ReadOnlyList (List<G>? list = null) {
- this.list = list;
- }
-
- /**
- * @inheritDoc
- */
- public Type element_type {
- get { return typeof (G); }
- }
-
- /**
- * @inheritDoc
- */
- public Gee.Iterator<G> iterator () {
- if (_list == null) {
- return new Iterator<G> ();
- }
-
- return _list.iterator ();
- }
-
- /**
- * @inheritDoc
- */
- public bool contains (G item) {
- if (_list == null) {
- return false;
- }
-
- return _list.contains (item);
+ base (list);
}
/**
* @inheritDoc
*/
public int index_of (G item) {
- if (_list == null) {
+ if (_collection == null) {
return -1;
}
- return _list.index_of (item);
- }
-
- /**
- * Unimplemented method (read only list).
- */
- public bool add (G item) {
- assert_not_reached ();
- }
-
- /**
- * Unimplemented method (read only list).
- */
- public bool remove (G item) {
- assert_not_reached ();
+ return ((Gee.List<G>) _collection).index_of (item);
}
/**
@@ -138,11 +72,11 @@ public class Gee.ReadOnlyList<G> : Object, Iterable<G>, Collection<G>, List<G> {
* @inheritDoc
*/
public new G? get (int index) {
- if (_list == null) {
+ if (_collection == null) {
return null;
}
- return _list.get (index);
+ return ((Gee.List<G>) _collection).get (index);
}
/**
@@ -153,13 +87,6 @@ public class Gee.ReadOnlyList<G> : Object, Iterable<G>, Collection<G>, List<G> {
}
/**
- * @inheritDoc
- */
- public void clear () {
- assert_not_reached ();
- }
-
- /**
* Unimplemented method (read only list).
*/
public List<G>? slice (int start, int stop) {
@@ -167,56 +94,25 @@ public class Gee.ReadOnlyList<G> : Object, Iterable<G>, Collection<G>, List<G> {
}
/**
- * Unimplemented method (read only list).
- */
- public bool add_all (Collection<G> collection) {
- assert_not_reached ();
- }
-
- /**
- * @inheritDoc
- */
- public bool contains_all (Collection<G> collection) {
- if (_list == null) {
- return false;
- }
- return _list.contains_all (collection);
- }
-
- /**
- * Unimplemented method (read only list).
- */
- public bool remove_all (Collection<G> collection) {
- assert_not_reached ();
- }
-
- /**
- * Unimplemented method (read only list).
- */
- public bool retain_all (Collection<G> collection) {
- assert_not_reached ();
- }
-
- /**
* @inheritDoc
*/
public G? first () {
- if (_list == null) {
+ if (_collection == null) {
return null;
}
- return _list.first ();
+ return ((Gee.List<G>) _collection).first ();
}
/**
* @inheritDoc
*/
public G? last () {
- if (_list == null) {
+ if (_collection == null) {
return null;
}
- return _list.last ();
+ return ((Gee.List<G>) _collection).last ();
}
/**
@@ -225,22 +121,5 @@ public class Gee.ReadOnlyList<G> : Object, Iterable<G>, Collection<G>, List<G> {
public void insert_all (int index, Collection<G> collection) {
assert_not_reached ();
}
-
- /**
- * @inheritDoc
- */
- public G[] to_array() {
- return _list.to_array ();
- }
-
- class Iterator<G> : Object, Gee.Iterator<G> {
- public bool next () {
- return false;
- }
-
- public new G? get () {
- return null;
- }
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]