[blam] Channel: Move the items to be in hash tables



commit 96ebf7353b7522d503cf245d0faaf36331135bd6
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Wed Sep 15 04:32:38 2010 +0100

    Channel: Move the items to be in hash tables

 src/Channel.cs      |   33 ++++++++++++++++-----------------
 src/ChannelGroup.cs |    9 +++++----
 2 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/src/Channel.cs b/src/Channel.cs
index fa9f32d..5da0f0b 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -18,7 +18,7 @@ namespace Imendio.Blam {
         int NrOfUnreadItems {get; }
         string Name {get; set; }
         string Url {get; set; }
-        ArrayList Items {get; set; }
+        Hashtable Items {get; set; }
         Gtk.TreeIter Iter {get; set; }
         bool MarkAsRead();
         Item GetItem(string id);
@@ -93,9 +93,9 @@ namespace Imendio.Blam {
             }
         }
 
-		ArrayList mItems;
-		[XmlElement ("Item", typeof (Item))]
-		public ArrayList Items {
+		Hashtable mItems;
+        [XmlIgnore]
+		public Hashtable Items {
 			get {
 				return mItems;
 			}
@@ -116,28 +116,22 @@ namespace Imendio.Blam {
 
 		public Channel ()
 		{
-			mItems = new ArrayList ();
+			mItems = new Hashtable ();
 			mIter = new Gtk.TreeIter();
 		}
 
 		public Channel (string name, string url)
 		{
-			mItems = new ArrayList ();
+			mItems = new Hashtable ();
 			mIter = new Gtk.TreeIter();
 			Name = name;
 			Url = url;
 		}
 
-		public Item GetItem (string id)
-		{
-			foreach (Item item in mItems) {
-				if (item.Id == id) {
-					return item;
-				}
-			}
-
-			return null;
-		}
+        public Item GetItem (string id)
+        {
+            return mItems[id] as Item;
+        }
 
 		public bool MarkAsRead ()
 		{
@@ -176,6 +170,11 @@ namespace Imendio.Blam {
 			}
 		}
 
+        public void Add(Item item)
+        {
+
+        }
+
         public bool UpdateItem(string id, SyndicationItem SyndItem)
         {
             Item item = GetItem(id);
@@ -184,7 +183,7 @@ namespace Imendio.Blam {
                 item = new Item(SyndItem);
 
                 item.Unread = !Application.TheApp.CCollection.CheckItemIdReadInAllChannels(id);
-                mItems.Add(item);
+                mItems.Add(item.Id, item);
 
                 return true;
             } else {
diff --git a/src/ChannelGroup.cs b/src/ChannelGroup.cs
index 2166e3c..78f88ac 100644
--- a/src/ChannelGroup.cs
+++ b/src/ChannelGroup.cs
@@ -16,14 +16,15 @@ namespace Imendio.Blam
         [XmlAttribute("Name")] public string Int_Name = null;
         [XmlAttribute("Url")] public string Int_Url = null;
         [XmlElement("Channel", typeof(Channel))] public ArrayList Channels;
-        private ArrayList dummy;
+        private Hashtable dummy;
         private Gtk.TreeIter mIter;
 
-        public ArrayList Items {
+        public Hashtable Items {
             get { /* FIXME: Cache this value. */
-                ArrayList tmp = new ArrayList();
+                Hashtable tmp = new Hashtable();
                 foreach(Channel chan in Channels){
-                    tmp.AddRange(chan.Items);
+                    foreach(DictionaryEntry de in chan.Items)
+                    tmp.Add(de.Key, de.Value);
                 }
                 return tmp;
             }



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