[libgee] Move virtual methods to List interface
- From: Maciej Marcin Piechotka <mpiechotka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgee] Move virtual methods to List interface
- Date: Sun, 19 Aug 2012 02:59:31 +0000 (UTC)
commit a35285be43db62924dff0ef8f6441bc411c2dd26
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Sat Aug 18 18:41:02 2012 -0700
Move virtual methods to List interface
gee/abstractlist.vala | 34 ----------------------------------
gee/linkedlist.vala | 4 ++--
gee/list.vala | 23 +++++++++++++++++++----
3 files changed, 21 insertions(+), 40 deletions(-)
---
diff --git a/gee/abstractlist.vala b/gee/abstractlist.vala
index 1e760f9..ee7ca2a 100644
--- a/gee/abstractlist.vala
+++ b/gee/abstractlist.vala
@@ -66,40 +66,6 @@ public abstract class Gee.AbstractList<G> : Gee.AbstractCollection<G>, List<G> {
*/
public abstract List<G>? slice (int start, int stop);
- /**
- * { inheritDoc}
- */
- public virtual G first () {
- return get (0);
- }
-
- /**
- * { inheritDoc}
- */
- public virtual G last () {
- return get (size - 1);
- }
-
- /**
- * { inheritDoc}
- */
- public virtual void insert_all (int index, Collection<G> collection) {
- foreach (G item in collection) {
- insert(index, item);
- index++;
- }
- }
-
- /**
- * { inheritDoc}
- */
- public void sort (owned CompareDataFunc<G>? compare = null) {
- if (compare == null) {
- compare = Functions.get_compare_func_for (typeof (G));
- }
- TimSort.sort<G> (this, compare);
- }
-
private weak List<G> _read_only_view;
/**
diff --git a/gee/linkedlist.vala b/gee/linkedlist.vala
index 2b7e4e4..0bc17e5 100644
--- a/gee/linkedlist.vala
+++ b/gee/linkedlist.vala
@@ -261,7 +261,7 @@ public class Gee.LinkedList<G> : AbstractBidirList<G>, Queue<G>, Deque<G> {
/**
* { inheritDoc}
*/
- public override G first () {
+ public G first () {
assert (_size > 0);
return _head.data;
}
@@ -269,7 +269,7 @@ public class Gee.LinkedList<G> : AbstractBidirList<G>, Queue<G>, Deque<G> {
/**
* { inheritDoc}
*/
- public override G last () {
+ public G last () {
assert (_size > 0);
return _tail.data;
}
diff --git a/gee/list.vala b/gee/list.vala
index 84ebd2b..5f08aba 100644
--- a/gee/list.vala
+++ b/gee/list.vala
@@ -23,6 +23,7 @@
/**
* An ordered collection.
*/
+[GenericAccessors]
public interface Gee.List<G> : Collection<G> {
/**
* Returns a ListIterator that can be used for iteration over this list.
@@ -88,14 +89,18 @@ public interface Gee.List<G> : Collection<G> {
*
* @return first item in the list
*/
- public abstract G first ();
+ public virtual G first () {
+ return get (0);
+ }
/**
* Returns the last item of the list. Fails if the list is empty.
*
* @return last item in the list
*/
- public abstract G last ();
+ public virtual G last () {
+ return get (size - 1);
+ }
/**
* Inserts items into this list for the input collection at the
@@ -104,14 +109,24 @@ public interface Gee.List<G> : Collection<G> {
* @param index zero-based index of the items to be inserted
* @param collection collection of items to be inserted
*/
- public abstract void insert_all (int index, Collection<G> collection);
+ public virtual void insert_all (int index, Collection<G> collection) {
+ foreach (G item in collection) {
+ insert(index, item);
+ index++;
+ }
+ }
/**
* Sorts items by comparing with the specified compare function.
*
* @param compare_func compare function to use to compare items
*/
- public abstract void sort (owned CompareDataFunc<G>? compare_func = null);
+ public virtual void sort (owned CompareDataFunc<G>? compare_func = null) {
+ if (compare_func == null) {
+ compare_func = Functions.get_compare_func_for (typeof (G));
+ }
+ TimSort.sort<G> (this, compare_func);
+ }
/**
* The read-only view of this list.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]