/// <summary> /// Returns true if it added a new reocrd, false if updated a current record /// </summary> /// <param name="R"></param> /// <param name="CM"></param> /// <returns></returns> public bool Merge(Record R, CompoundRecord CM) { // Check to see if it exists // CompoundRecord cr; bool b = this._cache.TryGetValue(R, out cr); // If exists, then merge // if (b == true) { this._Reducers.Merge(CM, cr); } else { this._cache.Add(R, CM); } return !b; }
// Statics // /// <summary> /// Creates a compound record from a fat record; this is essentially the inverse of ToRecord /// </summary> /// <param name="R">A fat record to be transformed</param> /// <param name="Sig">An array of index values that define the size of a sub-element of the compound record</param> /// <returns>A compound record</returns> public static CompoundRecord FromRecord(Record R, int[] Sig) { CompoundRecord cr = new CompoundRecord(Sig.Length); int k = 0; for (int i = 0; i < Sig.Length; i++) { List<Cell> c = new List<Cell>(); for (int j = 0; j < Sig[i]; j++) { c.Add(R[k]); k++; } cr[i] = new Record(c.ToArray()); } return cr; }
public Record Evaluate(CompoundRecord WorkData) { List<Cell> c = new List<Cell>(this.Count); for (int i = 0; i < this.Count; i++) { c.Add(this._cache[i].Evaluate(WorkData[i])); } return new Record(c.ToArray()); }
public void Merge(CompoundRecord WorkData, CompoundRecord MergeIntoWorkData) { for (int i = 0; i < this.Count; i++) { this._cache[i].Merge(WorkData[i], MergeIntoWorkData[i]); } }
public void Accumulate(CompoundRecord WorkData) { for (int i = 0; i < this.Count; i++) { this._cache[i].Accumulate(WorkData[i]); } }
public CompoundRecord Initialize() { CompoundRecord cr = new CompoundRecord(this.Count); for (int i = 0; i < this.Count; i++) { cr[i] = this._cache[i].Initialize(); } return cr; }