Example #1
0
            /// <summary>
            /// Decremente o contador para verificação de repetições.
            /// </summary>
            protected override void DecrementAffectations()
            {
                StructureAffector affector = this.thisFastAffector as StructureAffector;

                if (this.affectedIndices.ContainsKey(affector.affectorMatrix[this.currentPointer][this.currentAffectationIndices[this.currentPointer]]))
                {
                    --this.affectedIndices[affector.affectorMatrix[this.currentPointer][this.currentAffectationIndices[this.currentPointer]]];
                }
            }
Example #2
0
            /// <summary>
            /// Incremente o índice actual.
            /// </summary>
            /// <returns>
            /// Verdadeiro se o índice pode ser incrementado e falso caso contrário.
            /// </returns>
            protected override bool IncrementCurrent()
            {
                StructureAffector affector = this.thisFastAffector as StructureAffector;

                ++this.currentAffectationIndices[this.currentPointer];
                if (this.currentAffectationIndices[this.currentPointer] == affector.affectorMatrix[this.currentPointer].Length)
                {
                    return(false);
                }
                return(true);
            }
Example #3
0
            /// <summary>
            /// Obtém a afectação actual.
            /// </summary>
            /// <returns>
            /// A afectação.
            /// </returns>
            /// <exception cref="Exception">
            /// Se o enumerador se encontrar antes do início ao após o final da colecção.
            /// </exception>
            protected override int[] GetCurrent()
            {
                StructureAffector affector = this.thisFastAffector as StructureAffector;

                if (this.isBeforeStart)
                {
                    throw new CollectionsException("Enumerator is in \"IsBeforeStart\" status.");
                }

                if (this.isAfterEnd)
                {
                    throw new CollectionsException("Enumerator is in \"IsAfterEnd\" status.");
                }

                int[] result = new int[this.currentAffectationIndices.Length];
                for (int i = 0; i < this.currentAffectationIndices.Length; ++i)
                {
                    result[i] = affector.affectorMatrix[i][this.currentAffectationIndices[i]];
                }

                return(result);
            }
Example #4
0
            /// <summary>
            /// Verifica se o elemento corrente constitui ou não uma repetição.
            /// </summary>
            /// <returns>
            /// Verdadeiro caso existam repetições e falso caso contrário.
            /// </returns>
            protected override bool VerifyRepetitions()
            {
                StructureAffector affector = this.thisFastAffector as StructureAffector;
                int indexBeingAffected     = affector.affectorMatrix[this.currentPointer][this.currentAffectationIndices[this.currentPointer]];

                if (affector.numberOfPossibleAffectationsByIndice != null &&
                    affector.numberOfPossibleAffectationsByIndice.ContainsKey(indexBeingAffected))
                {
                    if (!this.affectedIndices.ContainsKey(indexBeingAffected))
                    {
                        if (affector.numberOfPossibleAffectationsByIndice[indexBeingAffected] == 0)
                        {
                            return(false);
                        }
                        else
                        {
                            this.affectedIndices.Add(indexBeingAffected, 0);
                        }
                    }

                    if (this.affectedIndices[indexBeingAffected] == affector.numberOfPossibleAffectationsByIndice[indexBeingAffected])
                    {
                        return(false);
                    }
                }
                else
                {
                    if (this.affectedIndices.ContainsKey(indexBeingAffected))
                    {
                        if (this.affectedIndices[indexBeingAffected] == 1)
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
Example #5
0
            /// <summary>
            /// Verifica a validade da afectação actual.
            /// </summary>
            /// <returns>
            /// Verdadeiro caso a afectação seja vaálida e falso caso contrário.
            /// </returns>
            protected override bool CheckForCurrAffectIndicesValidity()
            {
                StructureAffector affector = this.thisFastAffector as StructureAffector;

                return(this.currentAffectationIndices[this.currentPointer] != affector.affectorMatrix[this.currentPointer].Length);
            }
Example #6
0
 /// <summary>
 /// Instancia um novo objecto do tipo <see cref="StructureAffectorEnumerator"/>.
 /// </summary>
 /// <param name="structureAffector">O afectador.</param>
 public StructureAffectorEnumerator(StructureAffector structureAffector) : base(structureAffector)
 {
     this.currentAffectationIndices = new int[structureAffector.NumberOfPlaces];
 }