Move virtual methods to List interface
authorMaciej Piechotka <uzytkownik2@gmail.com>
Sun, 19 Aug 2012 01:41:02 +0000 (18:41 -0700)
committerMaciej Piechotka <uzytkownik2@gmail.com>
Sun, 19 Aug 2012 01:52:39 +0000 (18:52 -0700)
gee/abstractlist.vala
gee/linkedlist.vala
gee/list.vala

index 1e760f9..ee7ca2a 100644 (file)
@@ -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;
 
        /**
index 2b7e4e4..0bc17e5 100644 (file)
@@ -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;
        }
index 84ebd2b..5f08aba 100644 (file)
@@ -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.