public static double[] ratingVector(PreferenceArray prefs) { double[] numArray = new double[prefs.length()]; for (int i = 0; i < prefs.length(); i++) { numArray[i] = prefs.get(i).getValue(); } return(numArray); }
public override PreferenceArray getPreferencesForItem(long itemID) { int num; if (this.tempPrefs.Count == 0) { return(base.getDelegate().getPreferencesForItem(itemID)); } PreferenceArray array = null; try { array = base.getDelegate().getPreferencesForItem(itemID); } catch (NoSuchItemException) { } List <Preference> list = new List <Preference>(); foreach (KeyValuePair <long, PreferenceArray> pair in this.tempPrefs) { PreferenceArray array2 = pair.Value; num = 0; while (num < array2.length()) { if (array2.getItemID(num) == itemID) { list.Add(array2.get(num)); } num++; } } int num2 = (array == null) ? 0 : array.length(); int count = list.Count; int num4 = 0; PreferenceArray array3 = new GenericItemPreferenceArray(num2 + count); for (num = 0; num < num2; num++) { array3.set(num4++, array.get(num)); } foreach (Preference preference in list) { array3.set(num4++, preference); } if (array3.length() == 0) { throw new NoSuchItemException(itemID); } return(array3); }
protected void processLine <T>(string line, FastByIDMap <T> data, FastByIDMap <FastByIDMap <DateTime?> > timestamps, bool fromPriorData) { bool flag2; int num5; PreferenceArray array2; int num6; float num7; if ((line.Length == 0) || (line[0] == COMMENT_CHAR)) { return; } string[] strArray = line.Split(new char[] { this.delimiter }); string str = strArray[0]; string str2 = strArray[1]; string str3 = strArray[2]; bool flag = strArray.Length > 3; string timestampString = flag ? strArray[3] : null; long key = this.readUserIDFromString(str); long itemID = this.readItemIDFromString(str2); if (this.transpose) { long num3 = key; key = itemID; itemID = num3; } T local = data.get(key); if (!fromPriorData) { IEnumerable <Preference> source = (IEnumerable <Preference>)local; if (flag || !string.IsNullOrWhiteSpace(str3)) { num7 = float.Parse(str3, CultureInfo.InvariantCulture); flag2 = false; if (this.uniqueUserItemCheck && (source != null)) { foreach (Preference preference in source) { if (preference.getItemID() == itemID) { flag2 = true; preference.setValue(num7); break; } } } if (!flag2) { if (source == null) { source = new List <Preference>(5); data.put(key, (T)source); } if (source is IList <Preference> ) { ((IList <Preference>)source).Add(new GenericPreference(key, itemID, num7)); } } this.addTimestamp(key, itemID, timestampString, timestamps); return; } if (source != null) { IEnumerator <Preference> enumerator = ((IEnumerable <Preference>)source.ToArray <Preference>()).GetEnumerator(); while (enumerator.MoveNext()) { Preference current = enumerator.Current; if (current.getItemID() == itemID) { if (source is IList <Preference> ) { ((IList <Preference>)local).Remove(current); } break; } } } removeTimestamp(key, itemID, timestamps); return; } PreferenceArray array = (PreferenceArray)local; if (flag || !string.IsNullOrWhiteSpace(str3)) { num7 = float.Parse(str3, CultureInfo.InvariantCulture); flag2 = false; if (this.uniqueUserItemCheck && (array != null)) { for (num5 = 0; num5 < array.length(); num5++) { if (array.getItemID(num5) == itemID) { flag2 = true; array.setValue(num5, num7); break; } } } } else { if (array != null) { flag2 = false; int num4 = array.length(); for (num5 = 0; num5 < num4; num5++) { if (array.getItemID(num5) == itemID) { flag2 = true; break; } } if (flag2) { if (num4 == 1) { data.remove(key); } else { array2 = new GenericUserPreferenceArray(num4 - 1); num5 = 0; for (num6 = 0; num5 < num4; num6++) { if (array.getItemID(num5) == itemID) { num6--; } else { array2.set(num6, array.get(num5)); } num5++; } data.put(key, (T)array2); } } } removeTimestamp(key, itemID, timestamps); goto Label_02F1; } if (!flag2) { if (array == null) { array = new GenericUserPreferenceArray(1); } else { array2 = new GenericUserPreferenceArray(array.length() + 1); num5 = 0; for (num6 = 1; num5 < array.length(); num6++) { array2.set(num6, array.get(num5)); num5++; } array = array2; } array.setUserID(0, key); array.setItemID(0, itemID); array.setValue(0, num7); data.put(key, (T)array); } Label_02F1: this.addTimestamp(key, itemID, timestampString, timestamps); }