private void NewGroup(DataItem di, List<Group> al, out Group g) { g = new Group(); g.keys = new object[attrs.Length]; int iKey = 0; foreach (int a in attrs) g.keys[iKey++] = di[a]; if (al == null) al = new List<Group>(); g.hashcode = di.GetSpecificHashCode(attrs); al.Add(g); ht[g.hashcode] = al; }
/// <summary> /// Find the appropriate group for this DataItem object /// </summary> /// <param name="di">The input DataItem</param> /// <param name="g">The group that the DataItem belongs to</param> /// <returns>True if this group already exists, false if this is a new group</returns> protected bool FindGroup(DataItem di, out Group g) { bool fExists = false; if (attrs == null) { fExists = (gTotal != null); if (!fExists) { gTotal = new Group(); gTotal.keys = null; } g = gTotal; return fExists; } int hc = di.GetSpecificHashCode(attrs); if (!ht.ContainsKey(hc)) NewGroup(di, null, out g); else { bool fMatch = false; bool fEq; List<Group> al = ht[hc]; g = null; for (int i = 0; fMatch == false && i < al.Count; i++) { g = al[i]; fEq = true; for (int j = 0; fEq && j < g.keys.Length; j++) fEq &= di[attrs[j]].Equals(g.keys[j]); fMatch = fEq; } fExists = fMatch; if (fMatch == false) NewGroup(di, al, out g); } return fExists; }