public void Add (Topic t) { Count++; if (topics == null) topics = t; else { if (!(topics is ArrayList)){ Topic temp = (Topic) topics; topics = new ArrayList (); ((ArrayList)topics).Add (temp); } ((ArrayList)topics).Add (t); } }
// // Constructor from a stream // public IndexEntry (FileStream fs, BinaryReader reader, int position) { Count = reader.ReadInt32 (); int caption_offset = reader.ReadInt32 (); string caption; if (Count == 1){ int url_offset = reader.ReadInt32 (); fs.Position = caption_offset; caption = reader.ReadString (); fs.Position = url_offset; string url = reader.ReadString (); topics = new Topic (caption, "", url); } else { ArrayList l = new ArrayList (Count); topics = l; int [] offsets = new int [Count]; for (int i = 0; i < Count; i++){ offsets [i] = reader.ReadInt32 (); } fs.Position = caption_offset; caption = reader.ReadString (); for (int i = 0; i < Count; i++){ fs.Position = offsets [i]; string url = reader.ReadString (); l.Add (new Topic (caption, "", url)); } } }
public void Add (string caption, string sort_key, string url) { Topic t = new Topic (caption, sort_key, url); AddTopic (t); }
public void AddTopic (Topic topic) { IndexEntry entry = (IndexEntry) entries [topic.SortKey]; if (entry == null){ entry = new IndexEntry (); entries [topic.SortKey] = entry; } add_string (topic.SortKey); add_string (topic.Caption); add_string (topic.Url); entry.Add (topic); }