[gnome-contacts] Add helper to get first item in a container



commit 4dd5dd5a31cc5cafe787c5b49b944a4b4e940cc0
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jun 23 14:57:13 2011 +0200

    Add helper to get first item in a container

 src/contacts-utils.vala |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index 1c0a0ea..3f5eab7 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -19,6 +19,7 @@
 
 using Gtk;
 using Folks;
+using Gee;
 
 public class Contacts.Utils : Object {
   public static void compose_mail (string email) {
@@ -41,4 +42,11 @@ public class Contacts.Utils : Object {
     var request = new TelepathyGLib.AccountChannelRequest(account, request_dict, int64.MAX);
     request.ensure_channel_async.begin ("org.freedesktop.Telepathy.Client.Empathy.Chat", null);
   }
+
+  public static T? get_first<T> (Collection<T> collection) {
+    var i = collection.iterator();
+    if (i.next())
+      return i.get();
+    return null;
+  }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]