/// <summary> /// /// </summary> /// <returns></returns> public CustomIndex Copy() { CustomIndex ci = new CustomIndex(Index, Comparer); ci.MergeWith(this); return(ci); }
/// <summary> /// Makes a new smaller list of CustomIndices which still fits every CustomIndex /// </summary> /// <param name="customIndices">The CustomIndices that it has to support</param> /// <returns></returns> public static List <CustomIndex> OptimizeCustomIndices(List <CustomIndex> customIndices) { List <CustomIndex> newCustomIndices = new List <CustomIndex>(); // Try merging together CustomIndices as much as possible foreach (CustomIndex ci in customIndices) { CustomIndex mergingWith = newCustomIndices.Find(o => o.CanMerge(ci)); if (mergingWith != null) { mergingWith.MergeWith(ci); } else { // There is no CustomIndex to merge with so add a new one newCustomIndices.Add(ci.Copy()); } } // Remove any CustomIndices that might be obsolete newCustomIndices.RemoveAll(o => !IsUseful(o, newCustomIndices.Except(new[] { o }).ToList(), customIndices)); return(newCustomIndices); }