[geary/wip/iterate-723208: 1/3] Add basic Geary.iterate call
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/iterate-723208: 1/3] Add basic Geary.iterate call
- Date: Wed, 29 Jan 2014 02:54:05 +0000 (UTC)
commit a3d1ee066a700ec2deedc7d21eefe4ed449fb60b
Author: Charles Lindsay <chaz yorba org>
Date: Tue Jan 28 18:35:39 2014 -0800
Add basic Geary.iterate call
src/engine/util/util-iterable.vala | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/engine/util/util-iterable.vala b/src/engine/util/util-iterable.vala
index 4eb004a..4407c92 100644
--- a/src/engine/util/util-iterable.vala
+++ b/src/engine/util/util-iterable.vala
@@ -11,6 +11,22 @@ namespace Geary {
public Geary.Iterable<G> traverse<G>(Gee.Iterable<G> i) {
return new Geary.Iterable<G>(i.iterator());
}
+
+ /**
+ * Take some non-null items (all must be of type G) and return a
+ * Geary.Iterable for convenience.
+ */
+ public Geary.Iterable<G> iterate<G>(G g, ...) {
+ va_list args = va_list();
+ G arg = g;
+
+ Gee.ArrayList<G> list = new Gee.ArrayList<G>();
+ do {
+ list.add(arg);
+ } while((arg = args.arg()) != null);
+
+ return Geary.traverse<G>(list);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]