diff options
author | Regis Merlino <regis.merlino@intel.com> | 2013-03-21 11:03:51 +0100 |
---|---|---|
committer | Regis Merlino <regis.merlino@intel.com> | 2013-03-21 11:07:43 +0100 |
commit | f3823f10612b7b0c6796a1041187999ba4afd887 (patch) | |
tree | e2b349b0e1477ee2d5864398e875b45a42c1d7af /gee/list.vala | |
parent | 2306f3b30cc3117079c0cfcb8f2cad9720b141ab (diff) | |
download | libgee-f3823f10612b7b0c6796a1041187999ba4afd887.tar.gz libgee-f3823f10612b7b0c6796a1041187999ba4afd887.tar.bz2 libgee-f3823f10612b7b0c6796a1041187999ba4afd887.zip |
Update libgee to 0.9.92 (3462b25)
Diffstat (limited to 'gee/list.vala')
-rw-r--r-- | gee/list.vala | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/gee/list.vala b/gee/list.vala index d5193e3..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 (CompareFunc? 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. |