下面列出了java.util.ArrayDeque#addAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
void computeIndirectRelationships() {
ArrayDeque<InheritanceGraphNode> toVisit = new ArrayDeque<>();
toVisit.addAll(directChildren);
while (!toVisit.isEmpty()) {
InheritanceGraphNode child = toVisit.pop();
children.add(child);
toVisit.addAll(child.directChildren);
}
toVisit.addAll(directParents);
while (!toVisit.isEmpty()) {
InheritanceGraphNode parent = toVisit.pop();
parents.add(parent);
toVisit.addAll(parent.directParents);
}
}
@Override
public List<ValidationMessage> validate(Archetype archetype) {
List<ValidationMessage> result = new ArrayList<>();
beginValidation(archetype);
ArrayDeque<CObject> workList = new ArrayDeque<>();
workList.add(archetype.getDefinition());
while(!workList.isEmpty()) {
CObject cObject = workList.pop();
result.addAll(validate(cObject));
for(CAttribute attribute: cObject.getAttributes()) {
result.addAll(validate(attribute));
workList.addAll(attribute.getChildren());
}
}
result.addAll(endValidation(archetype));
return result;
}
/**
* Return a queue of message packets for delivery to remote identity with given public key.
*
* If recipientPublicKey is null, queues most recent messages
*/
private ArrayDeque<MessagePacket> getMessagesForIdentity(@Nullable byte[] recipientPublicKey, int maxMessages) {
ArrayDeque<MessagePacket> messagePacketQueue = new ArrayDeque<>();
if (recipientPublicKey != null) {
// Get messages not delievered to peer
pro.dbro.ble.data.model.Peer recipient = mDataStore.getPeerByPubKey(recipientPublicKey);
List<MessagePacket> messages = mDataStore.getOutgoingMessagesForPeer(recipient, maxMessages);
if (messages == null || messages.size() == 0) {
Timber.d("Got no messages for peer with pub key " + DataUtil.bytesToHex(recipientPublicKey));
} else {
messagePacketQueue.addAll(messages);
}
} else {
// Get most recent messages
MessageCollection recentMessages = mDataStore.getRecentMessages();
for (int x = 0; x < Math.min(maxMessages, recentMessages.getCursor().getCount()); x++) {
Message currentMessage = recentMessages.getMessageAtPosition(x);
if (currentMessage != null)
messagePacketQueue.add(currentMessage.getProtocolMessage(mDataStore));
}
recentMessages.close();
}
return messagePacketQueue;
}
public void test_spliterator() throws Exception {
ArrayList<Integer> testElements = new ArrayList<>(
Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
ArrayDeque<Integer> adq = new ArrayDeque<>();
adq.addAll(testElements);
SpliteratorTester.runBasicIterationTests(adq.spliterator(), testElements);
SpliteratorTester.runBasicSplitTests(adq, testElements);
SpliteratorTester.testSpliteratorNPE(adq.spliterator());
assertTrue(adq.spliterator().hasCharacteristics(
Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED));
SpliteratorTester.runOrderedTests(adq);
SpliteratorTester.runSizedTests(adq, 16 /* expected size */);
SpliteratorTester.runSubSizedTests(adq, 16 /* expected size */);
SpliteratorTester.assertSupportsTrySplit(adq);
}
public void visitExplicitInputs(
ImmutableSortedMap<PathFragment, PhonyTarget> phonyTargetsMap,
Consumer<ImmutableList<PathFragment>> consumer) {
consumer.accept(directExplicitInputs);
ArrayDeque<PathFragment> queue = new ArrayDeque<>(phonyNames);
Set<PathFragment> visited = Sets.newHashSet();
while (!queue.isEmpty()) {
PathFragment fragment = queue.remove();
if (visited.add(fragment)) {
PhonyTarget phonyTarget = Preconditions.checkNotNull(phonyTargetsMap.get(fragment));
consumer.accept(phonyTarget.getDirectExplicitInputs());
queue.addAll(phonyTarget.getPhonyNames());
}
}
}
/**
* Each NinjaTarget should be parsed in the context of it's parent {@link NinjaScope}. (All the
* variables in targets are immediately expanded.) We are iterating main and all transitively
* included scopes, and parsing corresponding targets.
*/
private List<NinjaTarget> iterateScopesScheduleTargetsParsing(
NinjaScope scope, Map<NinjaScope, List<FileFragment>> rawTargets)
throws GenericParsingException, InterruptedException {
ArrayDeque<NinjaScope> queue = new ArrayDeque<>();
queue.add(scope);
CollectingListFuture<NinjaTarget, GenericParsingException> future =
new CollectingListFuture<>(GenericParsingException.class);
while (!queue.isEmpty()) {
NinjaScope currentScope = queue.removeFirst();
List<FileFragment> targetFragments = rawTargets.get(currentScope);
Preconditions.checkNotNull(targetFragments);
for (FileFragment fragment : targetFragments) {
future.add(
service.submit(
() ->
new NinjaParserStep(
new NinjaLexer(fragment), pathFragmentInterner, nameInterner)
.parseNinjaTarget(currentScope, fragment.getFragmentOffset())));
}
queue.addAll(currentScope.getIncludedScopes());
queue.addAll(currentScope.getSubNinjaScopes());
}
return future.getResult();
}
void releaseAllResources() throws IOException {
ArrayDeque<Buffer> releasedBuffers = new ArrayDeque<>();
boolean shouldRelease = false;
synchronized (receivedBuffers) {
if (!isReleased) {
isReleased = true;
shouldRelease = true;
releasedBuffers.addAll(receivedBuffers);
receivedBuffers.clear();
}
}
if (shouldRelease) {
bufferManager.releaseAllBuffers(releasedBuffers);
}
}
/**
* Loops through all resource roots that have been made available transitively via Class-Path entries, and
* adds them to the list of roots to be processed.
*/
private Collection<? extends ResourceRoot> handleClassPathItems(final DeploymentUnit deploymentUnit) {
final Set<ResourceRoot> additionalRoots = new HashSet<ResourceRoot>();
final ArrayDeque<ResourceRoot> toProcess = new ArrayDeque<ResourceRoot>();
final List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
toProcess.addAll(resourceRoots);
final Set<ResourceRoot> processed = new HashSet<ResourceRoot>(resourceRoots);
while (!toProcess.isEmpty()) {
final ResourceRoot root = toProcess.pop();
final List<ResourceRoot> classPathRoots = root.getAttachmentList(Attachments.CLASS_PATH_RESOURCE_ROOTS);
for(ResourceRoot cpRoot : classPathRoots) {
if(!processed.contains(cpRoot)) {
additionalRoots.add(cpRoot);
toProcess.add(cpRoot);
processed.add(cpRoot);
}
}
}
return additionalRoots;
}
/**
* addAll of a collection with null elements throws NPE
*/
public void testAddAll2() {
ArrayDeque q = new ArrayDeque();
try {
q.addAll(Arrays.asList(new Integer[SIZE]));
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* addAll of a collection with any null elements throws NPE after
* possibly adding some elements
*/
public void testAddAll3() {
ArrayDeque q = new ArrayDeque();
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE - 1; ++i)
ints[i] = new Integer(i);
try {
q.addAll(Arrays.asList(ints));
shouldThrow();
} catch (NullPointerException success) {}
}
public void iterate(Consumer<NinjaScope> consumer) {
ArrayDeque<NinjaScope> queue = new ArrayDeque<>();
queue.add(this);
while (!queue.isEmpty()) {
NinjaScope currentScope = queue.removeFirst();
consumer.accept(currentScope);
queue.addAll(currentScope.getIncludedScopes());
queue.addAll(currentScope.getSubNinjaScopes());
}
}
public static void stop(String tag) {
if (!enabled.get()) return;
ThreadPerformance threadPerformance = threadNode.get();
synchronized (threadPerformance) {
PerformanceNode last = threadPerformance.active.getLast();
if (last.tag.equals(tag) && !(last instanceof ThreadPerformance)) {
last.end = System.nanoTime() - startTime;
threadPerformance.active.remove(last);
} else {
Log.error("Performance: stopping tag '" + tag + "' when the last tag is '" + last.tag + "'");
PerformanceNode node = null;
for (PerformanceNode performanceNode : threadPerformance.active) {
if (performanceNode.tag.equals(tag)) {
node = performanceNode;
break;
}
}
if (node == null) {
Log.error("Performance: tag '" + tag + "' was never started");
return;
}
ArrayDeque<PerformanceNode> d = new ArrayDeque<PerformanceNode>();
d.add(node);
while (d.size() > 0) {
PerformanceNode n = d.removeFirst();
if (n.end == 0) {
n.end = System.nanoTime() - startTime;
threadPerformance.active.remove(n);
d.addAll(n.children);
}
}
}
}
}
/**
* addAll(null) throws NPE
*/
public void testAddAll1() {
ArrayDeque q = new ArrayDeque();
try {
q.addAll(null);
shouldThrow();
} catch (NullPointerException success) {}
}
private <T> boolean search(MimedType<T> target, ArrayDeque<PathInfo> bestMatch, ArrayDeque<PathInfo> currentPath, MimedType currentSearch, HashSet<MimedType> searched) {
if (target.isTypeOf(currentSearch)) {
bestMatch.clear();
bestMatch.addAll(currentPath);
return true;
}
// the current path must have potential to be better than the best match
if (!bestMatch.isEmpty() && PathInfo.distance(currentPath) >= PathInfo.distance(bestMatch))
return false;
// prevent reentrancy
if (searched.contains(currentSearch))
return false;
boolean found = false;
searched.add(currentSearch);
ConverterTransformers<Object, Object> converterTransformers = outputs.getAll(currentSearch);
for (MimedType candidate: converterTransformers.keySet()) {
// this simulates the mime results of a transform
MimedType newSearch = new MimedType(candidate.type, mimeReplace(currentSearch.mime, candidate.mime));
PathInfo path = new PathInfo();
path.transformer = converterTransformers.get(candidate);
path.mime = newSearch.mime;
path.candidate = candidate;
currentPath.addLast(path);
try {
found |= search(target, bestMatch, currentPath, newSearch, searched);
}
finally {
currentPath.removeLast();
}
}
if (found) {
// if this resulted in a success,
// clear this from the currentSearch list, because we know this leads
// to a potential solution. maybe we can arrive here faster.
searched.remove(currentSearch);
}
return found;
}
/**
* Create a graph that represents the relationship between the taxa.
* <p>
* Vertices in the new graph are the taxa keys. A transaction in the new
* graph from vertex A to vertex B represents all transactions from any
* vertex in taxon A to any vertex in taxon B.
* <p>
* @throws java.lang.InterruptedException If the thread is interrupted.
*
* @return A Condensation representing the relationship between the taxa.
*
* TODO: sometimes its not worth adding the transactions.
*/
public Condensation getCondensedGraph() throws InterruptedException {
// final Map<Integer, Extent> taxonKeyToExtent = new HashMap<>();
final Map<Integer, Integer> cVxIdToTaxonKey = new HashMap<>();
final Map<Integer, Integer> taxonKeyToVxId = new HashMap<>();
final GraphWriteMethods condensedGraph = new StoreGraph(wg.getSchema());
final int cxAttr = VisualConcept.VertexAttribute.X.ensure(condensedGraph);
final int cyAttr = VisualConcept.VertexAttribute.Y.ensure(condensedGraph);
final int czAttr = VisualConcept.VertexAttribute.Z.ensure(condensedGraph);
final int cxOrigId = condensedGraph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, X_ORIG, X_ORIG, null, null);
final int cyOrigId = condensedGraph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, Y_ORIG, Y_ORIG, null, null);
final int czOrigId = condensedGraph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, Z_ORIG, Z_ORIG, null, null);
final int cnRadiusAttr = VisualConcept.VertexAttribute.NODE_RADIUS.ensure(condensedGraph);
final int cRadiusAttr = VisualConcept.VertexAttribute.LABEL_RADIUS.ensure(condensedGraph);
// Add the vertices.
// TODO: do these need to be sorted?
for (final Integer k : getSortedTaxaKeys()) {
if (Thread.interrupted()) {
throw new InterruptedException();
}
if (taxa.get(k).isEmpty()) {
continue;
}
final int cVxId = condensedGraph.addVertex();
final BitSet vertices = new BitSet();
for (Integer member : taxa.get(k)) {
vertices.set(member);
}
// Figure out where and how big the new vertex will be.
final Extent extent = Extent.getExtent(wg, vertices);
// The condensation has the positions of the extents and the positions of the taxon key vertices.
// The x,y,z will be modified, so remember them for repositioning later.
condensedGraph.setFloatValue(cxAttr, cVxId, extent.getX());
condensedGraph.setFloatValue(cyAttr, cVxId, extent.getY());
condensedGraph.setFloatValue(czAttr, cVxId, extent.getZ());
condensedGraph.setFloatValue(cxOrigId, cVxId, extent.getX());
condensedGraph.setFloatValue(cyOrigId, cVxId, extent.getY());
condensedGraph.setFloatValue(czOrigId, cVxId, extent.getZ());
condensedGraph.setFloatValue(cnRadiusAttr, cVxId, extent.getNRadius());
condensedGraph.setFloatValue(cRadiusAttr, cVxId, extent.getLRadius());
cVxIdToTaxonKey.put(cVxId, k);
taxonKeyToVxId.put(k, cVxId);
// taxonKeyToExtent.put(k, extent);
}
// System.out.printf("@GT Condensation (nTaxa=%d) (vxCount %d->%d)\n", taxa.keySet().size(), graph.getVertexCount(), wg.getVertexCount());
// Add the transactions.
// final long t0 = System.currentTimeMillis();
// We search through all of the taxa to find sources,
// but only look in the remaining taxa for destinations,
// otherwise we end up with two transactions between each vertex.
final ArrayDeque<Integer> sources = new ArrayDeque<>();
sources.addAll(taxa.keySet());
while (!sources.isEmpty()) {
// If we already have a transaction from the current source to a particular destination,
// don't add another one.
final Set<Integer> found = new HashSet<>();
final Integer src = sources.removeFirst();
found.add(src);
final Set<Integer> members = taxa.get(src);
for (Integer mm : members) {
if (Thread.interrupted()) {
throw new InterruptedException();
}
final int m = mm;
final int nNeighbours = wg.getVertexNeighbourCount(m);
for (int position = 0; position < nNeighbours; position++) {
final int nbId = wg.getVertexNeighbour(m, position);
final Integer dst = nodeToTaxa != null ? nodeToTaxa.get(nbId) : findTaxonContainingVertex(sources, nbId);
// Found the test for null was required to avoid issues
if (dst != null && dst != Graph.NOT_FOUND && !found.contains(dst)) {
// Debug.debug("condense src=%s(%s) dst=%s(%s)\n", src, taxonKeyToVxId.get(src), dst, taxonKeyToVxId.get(dst));
condensedGraph.addTransaction(taxonKeyToVxId.get(src), taxonKeyToVxId.get(dst), true);
found.add(dst);
}
}
}
}
return new Condensation(condensedGraph, cVxIdToTaxonKey);//, taxonKeyToExtent);
}
@GuardedBy("this")
private void regenerateSortedNodes() {
mSortedNodes.clear();
if (mBindings.size() == 0) {
return;
}
final ArraySet<ValueNode> leafNodes = new ArraySet<>();
final SimpleArrayMap<ValueNode, Integer> nodesToOutputsLeft = new SimpleArrayMap<>();
for (int i = 0, bindingsSize = mBindings.size(); i < bindingsSize; i++) {
final ArrayList<ValueNode> nodes = mBindings.get(i).getAllNodes();
for (int j = 0, nodesSize = nodes.size(); j < nodesSize; j++) {
final ValueNode node = nodes.get(j);
final int outputCount = node.getOutputCount();
if (outputCount == 0) {
leafNodes.add(node);
} else {
nodesToOutputsLeft.put(node, outputCount);
}
}
}
if (!nodesToOutputsLeft.isEmpty() && leafNodes.isEmpty()) {
throw new DetectedCycleException(
"Graph has nodes, but they represent a cycle with no leaf nodes!");
}
final ArrayDeque<ValueNode> nodesToProcess = new ArrayDeque<>();
nodesToProcess.addAll(leafNodes);
while (!nodesToProcess.isEmpty()) {
final ValueNode next = nodesToProcess.pollFirst();
mSortedNodes.add(next);
NodeState nodeState = mNodeStates.get(next);
if (nodeState == null) {
String message =
next.getClass().getSimpleName() + " : InputNames " + next.buildDebugInputsString();
// Added for debugging T67342661
ComponentsReporter.emitMessage(
ComponentsReporter.LogLevel.ERROR, STATE_NOT_INTIALIZED_FOR_VALUE_NODE, message);
}
for (ValueNode input : next.getAllInputs()) {
final int outputsLeft = nodesToOutputsLeft.get(input) - 1;
nodesToOutputsLeft.put(input, outputsLeft);
if (outputsLeft == 0) {
nodesToProcess.addLast(input);
} else if (outputsLeft < 0) {
throw new DetectedCycleException("Detected cycle.");
}
}
}
int expectedTotalNodes = nodesToOutputsLeft.size() + leafNodes.size();
if (mSortedNodes.size() != expectedTotalNodes) {
throw new DetectedCycleException(
"Had unreachable nodes in graph -- this likely means there was a cycle");
}
Collections.reverse(mSortedNodes);
mIsDirty = false;
}
private void buildColumn(PresentationEnvironment env, TableColumnsElement columns, MetaResource resource, boolean filtersEnabled, boolean sortingEnabled,
ArrayDeque<MetaAttribute> attributePath) {
MetaAttribute lastAttribute = attributePath.getLast();
MetaType type = lastAttribute.getType();
if (type == null) {
return; // TODO support e.g. from other services
}
if (isIgnored(attributePath, env) || type.isCollection()) {
return;
}
String label = PresentationBuilderUtils.getLabel(attributePath);
if (type instanceof MetaDataObject && !lastAttribute.isAssociation()) {
for (MetaAttribute nestedAttribute : type.asDataObject().getAttributes()) {
if (!attributePath.contains(nestedAttribute)) {
ArrayDeque nestedPath = new ArrayDeque();
nestedPath.addAll(attributePath);
nestedPath.add(nestedAttribute);
buildColumn(env, columns, resource, filtersEnabled, sortingEnabled, nestedPath);
}
}
} else {
PresentationEnvironment cellEnv = env.clone();
cellEnv.setAttributePath(attributePath);
cellEnv.setAcceptedTypes(Arrays.asList(PresentationType.CELL, PresentationType.DISPLAY));
cellEnv.setType(type);
PresentationElement cellElement = env.createElement(cellEnv);
boolean sortable = sortingEnabled && lastAttribute.isSortable();
PathSpec pathSpec = PathSpec.of(attributePath.stream().map(it -> it.getName()).collect(Collectors.toList()));
//String valuePath = PresentationBuilderUtils.getValuePath(attributePath);
String id = pathSpec.toString(); //valuePath.join(valuePath, '.');
TableColumnElement column = new TableColumnElement();
column.setId(id);
column.setComponentId("column");
column.setLabel(label);
column.setAttributePath(pathSpec);
column.setEditable(env.isEditable());
column.setComponent(cellElement);
//column.setEditComponent();
// column.setFilter
column.setSortable(sortable);
// column.setWidth
// column.setTyleClass
columns.add(column);
}
}
private void buildElement(PresentationEnvironment env, FormElements elements, ArrayDeque<MetaAttribute> attributePath) {
MetaAttribute lastAttribute = attributePath.getLast();
MetaType type = lastAttribute.getType();
if (isIgnored(attributePath, env)) {
return;
}
String label = PresentationBuilderUtils.getLabel(attributePath);
if (type instanceof MetaDataObject && !lastAttribute.isAssociation()) {
for (MetaAttribute nestedAttribute : type.asDataObject().getAttributes()) {
if (!attributePath.contains(nestedAttribute)) {
ArrayDeque nestedPath = new ArrayDeque();
nestedPath.addAll(attributePath);
nestedPath.add(nestedAttribute);
buildElement(env, elements, nestedPath);
}
}
} else {
PresentationEnvironment elementEnv = env.clone();
elementEnv.setAttributePath(attributePath);
elementEnv.setAcceptedTypes(Arrays.asList(PresentationType.FORM_ELEMENT, PresentationType.DISPLAY));
elementEnv.setType(type);
PresentationElement element = env.createElement(elementEnv);
PathSpec pathSpec = PathSpec.of(attributePath.stream().map(it -> it.getName()).collect(Collectors.toList()));
//String valuePath = PresentationBuilderUtils.getValuePath(attributePath);
String id = pathSpec.toString(); //valuePath.join(valuePath, '.');
FormElement formElement = new FormElement();
formElement.setId(id);
formElement.setComponentId("form");
formElement.setLabel(label);
formElement.setAttributePath(pathSpec);
formElement.setEditable(env.isEditable());
formElement.setComponent(element);
//column.setEditComponent();
// column.setFilter
// column.setWidth
// column.setTyleClass
elements.add(formElement);
}
}
/**
* Looks at each action in {@code actionsToCheck} and determines whether additional artifacts,
* actions, and (in the case of {@link SkyframeAwareAction}s) other Skyframe nodes need to be
* restarted. If this finds more actions to restart, those actions are recursively checked too.
*/
private void checkActions(
ImmutableList<ActionAndLookupData> actionsToCheck,
Environment env,
MutableGraph<SkyKey> rewindGraph,
ImmutableList.Builder<Action> additionalActionsToRestart)
throws InterruptedException {
ArrayDeque<ActionAndLookupData> uncheckedActions = new ArrayDeque<>(actionsToCheck);
while (!uncheckedActions.isEmpty()) {
ActionAndLookupData actionAndLookupData = uncheckedActions.removeFirst();
ActionLookupData actionKey = actionAndLookupData.lookupData();
Action action = actionAndLookupData.action();
ArrayList<Artifact.DerivedArtifact> artifactsToCheck = new ArrayList<>();
ArrayList<ActionLookupData> newlyDiscoveredActions = new ArrayList<>();
if (action instanceof SkyframeAwareAction) {
// This action depends on more than just its input artifact values. We need to also restart
// the Skyframe subgraph it depends on, up to and including any artifacts, which may
// aggregate multiple actions.
addSkyframeAwareDepsAndGetNewlyVisitedArtifactsAndActions(
rewindGraph,
actionKey,
(SkyframeAwareAction) action,
artifactsToCheck,
newlyDiscoveredActions);
}
if (action.mayInsensitivelyPropagateInputs()) {
// Restarting this action won't recreate the missing input. We need to also restart this
// action's non-source inputs and the actions which created those inputs.
addPropagatingActionDepsAndGetNewlyVisitedArtifactsAndActions(
rewindGraph, actionKey, action, artifactsToCheck, newlyDiscoveredActions);
}
for (ActionLookupData actionLookupData : newlyDiscoveredActions) {
Action additionalAction =
checkNotNull(
ActionUtils.getActionForLookupData(env, actionLookupData), actionLookupData);
additionalActionsToRestart.add(additionalAction);
uncheckedActions.add(ActionAndLookupData.create(actionLookupData, additionalAction));
}
for (Artifact.DerivedArtifact artifact : artifactsToCheck) {
Map<ActionLookupData, Action> actionMap = getActionsForLostArtifact(artifact, env);
if (actionMap == null) {
continue;
}
ImmutableList<ActionAndLookupData> newlyVisitedActions =
addArtifactDepsAndGetNewlyVisitedActions(rewindGraph, artifact, actionMap);
additionalActionsToRestart.addAll(actions(newlyVisitedActions));
uncheckedActions.addAll(newlyVisitedActions);
}
}
}
<T> Optional<Pair<Falsification<T>, PrecursorDataPair<T>>> findFalsifyingValue(
Property<T> prop, LongSupplier clock) {
Guidance guidance = config.guidance();
Distribution<T> randomDistribution = new BoundarySkewedDistribution<>(config, prop.getGen());
ArrayDeque<long[]> toVisit = new ArrayDeque<>();
Distribution<T> distribution;
long endTime = clock.getAsLong() + config.testingTimeMillis();
for (int i = 0; i != config.examples(); i++) {
if (toVisit.isEmpty()) {
distribution = randomDistribution;
} else {
distribution = new ForcedDistribution<>(config, prop.getGen(), toVisit.pop());
}
PrecursorDataPair<T> t = distribution.generate();
if (checkHash(t)) {
continue;
}
examplesUsed = examplesUsed + 1;
guidance.newExample(t.precursor());
Optional<Falsification<T>> falsification = prop.tryFalsification(t.value());
guidance.exampleExecuted();
if (falsification.isPresent()) {
return falsification.map(f -> Pair.of(f, t));
} else {
toVisit.addAll(guidance.suggestValues(i,t.precursor()));
}
guidance.exampleComplete();
if (config.testingTimeMillis() > 0 && clock.getAsLong() > endTime) {
break;
}
}
return Optional.empty();
}