/// <summary> /// Instancia um novo objecto do tipo <see cref="StructureAffector"/>. /// </summary> /// <param name="affectorStructure">A matriz de afectação.</param> /// <exception cref="ArgumentNullException">Se a matriz de afectação for nula.</exception> /// <exception cref="ArgumentException">Se a matriz de afectação for vazia.</exception> public StructureAffector(ICollection <ICollection <int> > affectorStructure) { if (affectorStructure == null) { throw new ArgumentNullException("affectorStructure"); } if (affectorStructure.Count == 0) { throw new ArgumentException("Parameter collection affectorStructure must have elements to affect."); } this.affectorMatrix = new int[affectorStructure.Count][]; int pointer = 0; InsertionSortedCollection <int> sorter = new InsertionSortedCollection <int>(Comparer <int> .Default); var counter = 0; foreach (var item in affectorStructure) { sorter.Clear(); foreach (var innerItem in item) { if (!sorter.Contains(innerItem)) { sorter.Add(innerItem); } } this.affectorMatrix[pointer++] = sorter.ToArray(); counter += sorter.Count; } this.count = counter; this.numberOfPlaces = this.affectorMatrix.Length; }