我已经在一个编程项目上工作了一段时间,并且被困在其他人可能觉得微不足道的事情上。
我有一个struct数组,用于存储事件节点图的值。
一切正常,直到第85个循环,其枚举值为" ACTIVE"被分配给甚至没有被调用的数组(Q [0] .state)的一部分。
此时Q [notifydep] .state = QUEUED;应该发生(并且确实)。在这个循环中notifydep = 2。
问题出现在第一个实例的下面的代码中,它显示了Watch Point。 (在嵌套的for循环中)
以下是代码的一部分。我希望我能提供足够的代码而不是太多......
for (int w = qstarted; w < qendrunning; w++) {
PrintState(queue[w]);
if (Q[queue[w]].completetime == 0 && Q[queue[w]].state == ACTIVE) {
PrintState(queue[w]);
jobscopy[queue[w]].finishTime = currentday + 1;
Q[queue[w]].state = COMPLETED;
PrintState(queue[w]);
/*Put workers back into our available workers array*/
for (int i = 0; i < jobscopy[queue[w]].numPeopleUsed; i++) {
not_working_end++;
not_working[not_working_end] = jobscopy[queue[w]].peopleIDs[i];
}
/*Notify dependent jobs that this job has completed*/
for (int notify = 0; notify < Q[queue[w]].tocount; notify++) {
notifydep = Q[queue[w]].to[notify]; // ancestor job#
Q[notifydep].edges--; // decrement ancestor edge
/*check if notified job has 0 edges, if 0 then enqueue job*/
if (Q[notifydep].edges == 0 && Q[notifydep].state == WAITING) {
queue[qend++] = Q[notifydep].jobnum; // add job to qend then increment qend
Q[notifydep].state = QUEUED;
PrintState(notifydep);
cout << "\n" << __LINE__ << "============== Watch Point ===============";
PrintState(0);
}
}
cout << "\n============== Watch Point ===============";
PrintState(queue[w]);
cout << "\n" << __LINE__ << "============== Watch Point ===============";
PrintState(0);
dequeue(queue, w); // remove completed job from job running queue
curjobs--;
} else if (Q[queue[w]].completetime > 0 && Q[queue[w]].state == ACTIVE) {
Q[queue[w]].completetime--;
}
} // end check for completed jobs
这是我的.h
中结构的定义struct AdjacencyList {
NodeType state; // what is present state of job?
NodePath path; // is job part of critical path?
int jobnum;
int edges;
int tocount;
int fromcount;
int completetime;
int to[50];
int from[50];
};
非常感谢任何帮助。我对c ++很新,并且已经学到了很多东西。我首先花费了大量的精力进行研究和调试,然后在SO上讨论每个人。谢谢
SUB