public void buildExecutionTrace(List <DistributionElement> resultTraceElements, List <uint> proceduralRandomChoice, uint proceduralRandomChoiceIndex) { Debug.Assert((int)proceduralRandomChoiceIndex <= proceduralRandomChoice.Count - 1); if (proceduralRandomChoiceIndex == proceduralRandomChoice.Count - 1) { return; } uint currentProceduralRandomChoice = proceduralRandomChoice[(int)proceduralRandomChoiceIndex]; DistributionElement distributionElementToAdd = searchChildrenByProceduralRandomChoice(currentProceduralRandomChoice); resultTraceElements.Add(distributionElementToAdd); }
private void CloneDistributionWithDid(int sourceDid, int replaceCid, int replacedByCid) { // In the cloned distributions replaceCid is replaced by replacedByCid. // Get entry in _firstContinuationOfDistributionChainElement. var codEnumerator = _continuationOfDistributionChain.GetEnumerator(sourceDid); // Now every entry in the _continuationOfDistributionChain needs to be traversed and cloned. // During the traversal, a _distributionOfContinuationChain element needs to be added for every new // entry. var currentNewCofDChainIndex = -1; var newDistributionId = GetUnusedDistributionId(); var newDistributionElement = new DistributionElement { DistributionId = newDistributionId }; while (codEnumerator.MoveNext()) { Assert.That(_distributionOfContinuationChain.GetElementAtChainIndex(codEnumerator.CurrentChainIndex).DistributionId == sourceDid, "entry in _distributionOfContinuationChain is wrong"); var indexOfNewChainElements = GetUnusedChainIndex(); var cidOfNewElement = codEnumerator.CurrentElement.ContinuationId; if (cidOfNewElement == replaceCid) { cidOfNewElement = replacedByCid; } // Create entry in _continuationOfDistributionChain var continuationElement = new ContinuationElement { ContinuationId = cidOfNewElement }; if (currentNewCofDChainIndex == -1) { _continuationOfDistributionChain.StartChain(indexOfNewChainElements, newDistributionId, continuationElement); } else { _continuationOfDistributionChain.InsertChainElement(indexOfNewChainElements, newDistributionId, currentNewCofDChainIndex, continuationElement); } // Append entry in _distributionOfContinuationChain. May be a new chain _distributionOfContinuationChain.AppendChainElement(indexOfNewChainElements, cidOfNewElement, newDistributionElement); currentNewCofDChainIndex = indexOfNewChainElements; } }
private void CloneCidWithinDistributions(int sourceCid, int newCid) { // Get entry in _distributionOfContinuationChain. var oldChainEnumerator = _distributionOfContinuationChain.GetEnumerator(sourceCid); // Now every entry in the _distributionOfContinuationChain needs to be traversed and cloned. // During the traversal, a _continuationOfDistributionChain element needs to be added for every new // entry. We can reuse the pointer IndexInContinuationOfDistributionChain to find the insertion point. var currentNewDofCChainIndex = -1; while (oldChainEnumerator.MoveNext()) { // Note, chain congruence Assert.That(_continuationOfDistributionChain.GetElementAtChainIndex(oldChainEnumerator.CurrentChainIndex).ContinuationId == sourceCid, "entry in _continuationOfDistributionChain is wrong"); var indexOfNewChainElements = GetUnusedChainIndex(); // Create entry in _continuationOfDistributionChain. Because we clone, we know there is already a element _continuationOfDistributionChain.InsertChainElement(indexOfNewChainElements, oldChainEnumerator.CurrentElement.DistributionId, oldChainEnumerator.CurrentChainIndex, new ContinuationElement { ContinuationId = newCid }); // Create entry in _distributionOfContinuationChain var distributionElement = new DistributionElement { DistributionId = oldChainEnumerator.CurrentElement.DistributionId }; if (currentNewDofCChainIndex == -1) { _distributionOfContinuationChain.StartChain(indexOfNewChainElements, newCid, distributionElement); } else { _distributionOfContinuationChain.InsertChainElement(indexOfNewChainElements, newCid, currentNewDofCChainIndex, distributionElement); } currentNewDofCChainIndex = indexOfNewChainElements; } }