public object Clone() { IAttributeList TargetAttributeList = new IAttributeList(); foreach (Attribute attribute in AttributeList) { TargetAttributeList.Add(attribute); } return(TargetAttributeList.Count() > 0 ? (IAttributeList)TargetAttributeList.Clone() : null); }
public Item(string item_text, IAttributeList attributes, double distance, bool is_user, bool exists) { if (AttributeList == null) { AttributeList = (IAttributeList)attributes; } IsCentroid = is_user; Exists = exists; ItemText = item_text; Distance = distance; }
public object Clone() { IItemsList TargetItems = new IItemsList(); foreach (Item item in ItemsList) { IAttributeList TargetAttributeList = new IAttributeList(); foreach (Attribute attrib in item.GetAttributeList()) { TargetAttributeList.Add(new Attribute(attrib.Name, attrib.Value)); } if (TargetAttributeList.Count() > 0) { TargetItems.Add(new Item(item.ItemText, TargetAttributeList, item.Distance, item.IsCentroid, item.Exists)); } } return(TargetItems); }
public object Clone() { Item TargetItem = (Item)this.MemberwiseClone(); IAttributeList TargetAttributeList = new IAttributeList(); foreach (Attribute attribute in this.AttributeList) { TargetAttributeList.Add(attribute); } if (TargetAttributeList.Count() > 0) { TargetItem.AttributeList = (IAttributeList)TargetAttributeList.Clone(); } TargetItem.IsCentroid = this.IsCentroid; TargetItem.Exists = this.Exists; TargetItem.ItemText = this.ItemText; TargetItem.Distance = this.Distance; return(TargetItem); }
public static Dictionary <string, List <string> > LoadUserDataFromFile(string filename) { Dictionary <string, List <string> > usersWithSeenMovies = new Dictionary <string, List <string> >(); using (System.IO.FileStream fsFile = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) { using (System.IO.StreamReader fsStream = new System.IO.StreamReader( fsFile, System.Text.Encoding.UTF8, true, 128)) { string textBuf = "\0"; while ((textBuf = fsStream.ReadLine()) != null) { if (!String.IsNullOrEmpty(textBuf)) { IAttributeList TargetAttribList = new IAttributeList(); string sItemPattern = " => "; string[] sItemTokens; if ((sItemTokens = Regex.Split(textBuf, sItemPattern)) != null) { if (!usersWithSeenMovies.ContainsKey(sItemTokens[0])) { usersWithSeenMovies.Add(sItemTokens[0], new List <string> { sItemTokens[1] }); } else { usersWithSeenMovies[sItemTokens[0]].Add(sItemTokens[1]); } } } } fsStream.Close(); } fsFile.Close(); } return(usersWithSeenMovies); }