libgee r40 - in trunk: . gee
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: libgee r40 - in trunk: . gee
- Date: Tue, 27 Jan 2009 19:22:13 +0000 (UTC)
Author: juergbi
Date: Tue Jan 27 19:22:12 2009
New Revision: 40
URL: http://svn.gnome.org/viewvc/libgee?rev=40&view=rev
Log:
2009-01-27 JÃrg Billeter <j bitron ch>
* gee/arraylist.vala:
* gee/list.vala:
* gee/readonlylist.vala:
Add List.slice method, patch by Zeeshan Ali Khattak,
fixes bug 569188
Modified:
trunk/ChangeLog
trunk/gee/arraylist.vala
trunk/gee/list.vala
trunk/gee/readonlylist.vala
Modified: trunk/gee/arraylist.vala
==============================================================================
--- trunk/gee/arraylist.vala (original)
+++ trunk/gee/arraylist.vala Tue Jan 27 19:22:12 2009
@@ -128,6 +128,19 @@
_stamp++;
}
+ public List<G>? slice (int start, int stop) {
+ return_val_if_fail (start <= stop, null);
+ return_val_if_fail (start >= 0, null);
+ return_val_if_fail (stop <= this.size, null);
+
+ var slice = new ArrayList<G> (this._equal_func);
+ for (int i = start; i < stop; i++) {
+ slice.add (this[i]);
+ }
+
+ return slice;
+ }
+
private void shift (int start, int delta) {
assert (start >= 0 && start <= _size && start >= -delta);
Modified: trunk/gee/list.vala
==============================================================================
--- trunk/gee/list.vala (original)
+++ trunk/gee/list.vala Tue Jan 27 19:22:12 2009
@@ -63,5 +63,15 @@
* @param index zero-based index of the item to be removed
*/
public abstract void remove_at (int index);
+
+ /**
+ * Returns a slice of this list.
+ *
+ * @param start zero-based index of the begin of the slice
+ * @param stop zero-based index after the end of the slice
+ *
+ * @return A list containing a slice of this list
+ */
+ public abstract List<G>? slice (int start, int stop);
}
Modified: trunk/gee/readonlylist.vala
==============================================================================
--- trunk/gee/readonlylist.vala (original)
+++ trunk/gee/readonlylist.vala Tue Jan 27 19:22:12 2009
@@ -100,6 +100,10 @@
assert_not_reached ();
}
+ public List<G>? slice (int start, int stop) {
+ assert_not_reached ();
+ }
+
class Iterator<G> : Object, Gee.Iterator<G> {
public bool next () {
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]