本文整理汇总了C++中queue::pop方法的典型用法代码示例。如果您正苦于以下问题:C++ queue::pop方法的具体用法?C++ queue::pop怎么用?C++ queue::pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类queue
的用法示例。
在下文中一共展示了queue::pop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//freopen ("maze1.txt","r",stdin);
freopen ("maze1.in","r",stdin);
freopen ("maze1.out","w",stdout);
int r, c, i, j, k;
cin >> c >> r;
gets (s[0]);
for (i = 0; i <= 2*r; i++)
gets (s[i]);
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
if (s[2*i][2*j+1] == ' ') v[i][j][0] = 1;
if (s[2*i+1][2*j+2] == ' ') v[i][j][1] = 1;
if (s[2*i+2][2*j+1] == ' ') v[i][j][2] = 1;
if (s[2*i+1][2*j] == ' ') v[i][j][3] = 1;
}
}
//for (i = 0; i <= 2*r; i++)
//for (j = 0; j <= 2*c; j++)
PII now, e[2];
pair <PII,int> cur;
j = 0;
for (i = 0; i < r; i++)
{
if (v[i][0][3]) {
v[i][0][3] = 0;
e[j] = make_pair (i,0);
j++;
}
}
for (i = 0; i < c; i++)
{
if (v[0][i][0])
{
e[j] = make_pair (0,i);
v[0][i][0] = 0;
j++;
}
}
for (i = 0; i < r; i++)
{
if (v[i][c-1][1]) {
e[j] = make_pair (i,c-1);
v[i][c-1][1] = 0;
j++;
}
}
for (i = 0; i < c; i++)
{
if (v[r-1][i][2])
{
e[j] = make_pair (r-1,i);
v[r-1][i][2] = 0;
j++;
}
}
//cout << j << endl;
q.push (make_pair (e[0], 1));
q.push (make_pair (e[1], 1));
int ans = 0;
while (!q.empty()){
cur = q.front();
q.pop();
now = cur.x;
if (a[now.x][now.y]) continue;
a[now.x][now.y] = 1;
//cout << now.x << " " << now.y << endl;
ans = max (ans, cur.y);
for (i = 0; i < 4; i++)
{
if (now.x + X[i] < 0 || now.x + X[i] >= r) continue;
if (now.y + Y[i] < 0 || now.y + Y[i] >= c) continue;
if (!v[now.x][now.y][i]) continue;
if (a[now.x+X[i]][now.y+Y[i]]) continue;
q.push (make_pair (make_pair (now.x+X[i],now.y+Y[i]),cur.y+1));
}
}
//.........这里部分代码省略.........
示例2: main
int main()
{
//ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("000.txt","r",stdin);
//freopen("output.txt", "w", stdout);
#endif
/// MAIN
int i, t, j, k, l, keis=0, a, b, d, x, y;
takei(t);
while(t--)
{
takei(r);
takei(c);
//getchar();
for(i=0; i<r; i++)
scanf("%s", mat[i]);
for(i=0; i<r; i++)
for(j=0; j<c; j++)
level[0][i][j] = level[1][i][j] = 1000006;
while(qu1.size()) qu1.pop();
while(qu2.size()) qu2.pop();
for(i=0; i<r; i++)
for(j=0; j<c; j++)
if(mat[i][j]=='J')
{
qu1.push(i);
qu1.push(j);
level[0][i][j]=0;
i = j = r*c;
}
for(i=0; i<r; i++)
for(j=0; j<c; j++)
if(mat[i][j]=='F')
{
qu2.push(i);
qu2.push(j);
level[1][i][j] = 0;
}
BFS1();
BFS2();
int ans = 1000006;
for(i=0; i<c; i++)
for(j=0; j<c; j++)
{
if(i==0 or j==0 or i==r-1 or j==c-1)
{
if(level[0][i][j]<level[1][i][j])
ans = min(ans, level[0][i][j]);
}
}
if(ans < 1000006)
pf("%d\n", ans+1);
else
pf("IMPOSSIBLE\n");
}
/* Coding is FUN */
/// ENDD
return 0;
}
示例3: main
int main( ) {
freopen( "ttwo.in", "r", stdin );
freopen( "ttwo.out", "w", stdout );
for ( int i = 1; i < MAXN; ++i ) {
for ( int j = 1; j < MAXN; ++j ) {
scanf( " %c", &maze[i][j] );
}
}
for ( int i = 0; i <= MAXN; ++i ) {
maze[0][i] = '*';
maze[MAXN][i] = '*';
maze[i][0] = '*';
maze[i][MAXN] = '*';
}
state start;
for ( int i = 1; i <= MAXN; ++i )
for ( int j = 1; j <= MAXN; ++j ) {
if ( maze[i][j] == 'F' ) {
start.john_x = i;
start.john_y = j;
start.john_dir = NORTH;
maze[i][j] = '.';
}else if ( maze[i][j] == 'C' ) {
start.cow_x = i;
start.cow_y = j;
start.cow_dir = NORTH;
maze[i][j] = '.';
}
}
start.cost = 0;
q.push( start );
s.insert( vstate( start ) );
if ( check( start ) ) {
printf( "0\n" );
return 0;
}
while ( !q.empty() ) {
state top = q.front();
q.pop();
++top.cost;
state tmp = top;
if ( valid( top.cow_x + dx[ top.cow_dir ], top.cow_y + dy[ top.cow_dir ] ) ) {
if ( maze[ top.cow_x + dx[ top.cow_dir ] ][ top.cow_y + dy[ top.cow_dir ] ] == '*' ) {
tmp.cow_dir += 1;
tmp.cow_dir %= MODN;
}else {
tmp.cow_x += dx[ tmp.cow_dir ];
tmp.cow_y += dy[ tmp.cow_dir ];
}
}else {
tmp.cow_dir += 1;
tmp.cow_dir %= MODN;
}
if ( valid( top.john_x + dx[ top.john_dir ], top.john_y + dy[ top.john_dir ] ) ) {
if ( maze[ top.john_x + dx[ top.john_dir ] ][ top.john_y + dy[ top.john_dir ] ] == '*' ) {
tmp.john_dir += 1;
tmp.john_dir %= MODN;
}else {
tmp.john_x += dx[ tmp.john_dir ];
tmp.john_y += dy[ tmp.john_dir ];
}
}else {
tmp.john_dir += 1;
tmp.john_dir %= MODN;
}
if ( s.find( vstate( tmp ) ) == s.end( ) ) {
q.push( tmp );
s.insert( vstate( tmp ) );
if ( check( tmp ) ) {
printf( "%d\n", tmp.cost );
found = true;
break;
}
}
}
if ( !found ) {
//.........这里部分代码省略.........
示例4: next
/** @return the next smallest number */
int next() {
int ret = q.front();
q.pop();
return ret;
}
示例5: tournamentResults
/* tournamentResults() outputs the results of the tournament. It first gets
the name of the team that still has living fighters. It then copies all
fighters to a vector and adds the team points together, and then sorts the
vector in descending order based on points. The function outputs the team
with the last member(s) standing, then the winning team points, then
the individual winners.
Input: first team's queue of Creature pointers, first team's stack of loser
Creature pointers, second team's queue of Creature pointers, second
team's stack of loser Creature pointers
Output: none */
void tournamentResults(queue<Creature*>& lineup1, stack<Creature*>& loser1,
queue<Creature*>& lineup2, stack<Creature*>& loser2)
{
vector<Creature*> standings;
// store team with members still in queue
// last team standing
string lastTeam;
if (!lineup1.empty())
{
lastTeam = lineup1.front()->showTeam();
}
else
{
lastTeam = lineup2.front()->showTeam();
}
// get team names before putting fighters into the vector
string team1;
if (!lineup1.empty())
{
team1 = lineup1.front()->showTeam();
}
else
{
team1 = loser1.top()->showTeam();
}
string team2;
if (!lineup2.empty())
{
team2 = lineup2.front()->showTeam();
}
else
{
team2 = loser2.top()->showTeam();
}
// get team points while putting fighters into vector
int teamPts1 = 0;
// copy all Creatures to a vector
while (!lineup1.empty())
{
teamPts1 += lineup1.front()->showPoints();
standings.push_back(lineup1.front());
lineup1.pop();
}
while (!loser1.empty())
{
teamPts1 += loser1.top()->showPoints();
standings.push_back(loser1.top());
loser1.pop();
}
int teamPts2 = 0;
while (!lineup2.empty())
{
teamPts2 += lineup2.front()->showPoints();
standings.push_back(lineup2.front());
lineup2.pop();
}
while (!loser2.empty())
{
teamPts2 += loser2.top()->showPoints();
standings.push_back(loser2.top());
loser2.pop();
}
// sort in descending order by points the fighters
// bubble sort
Creature* temp;
bool swap;
do
{
swap = false;
for (unsigned int i = 0; i < (standings.size() - 1); i++)
{
if (standings.at(i)->showPoints() <
standings.at(i + 1)->showPoints())
{
temp = standings.at(i);
standings.at(i) = standings.at(i + 1);
standings.at(i + 1) = temp;
swap = true;
}
}
}
while (swap);
// // debugging
// for (unsigned int i = 0; i < standings.size(); i++)
//.........这里部分代码省略.........
示例6: CLR
template<class T> inline void CLR(queue<T> &Q){while (!Q.empty()) Q.pop();}
示例7: processEvent
//.........这里部分代码省略.........
}
if( _establishConnectionSubstate != _oldEstablishConnectionSubstate ) {
switch( _establishConnectionSubstate ) {
case EstablishConnectionInitialize:
Trace::out("->[Initialize connection establishment state machine]");
break;
case WaitForConnectionData:
Trace::out("\t- wait for connection data");
break;
case ProcessConnectionData:
Trace::out("\t- process connection data");
pushEvent( new XFNullTransition( WaitNullTransition::Id ) );
break;
default:
Trace::out("\t- undefined state error");
break;
}
}
if( _connectedSubstate != _oldConnectedSubstate ) {
switch( _connectedSubstate ) {
case ConnectedInitialize:
Trace::out("\t- initialize data transfer (alias 'connected') state machine");
break;
case SendQueuedDataPdu:
Trace::out("\t- send queued data pdu");
if(!txQueue.empty()) {
_transceiver->send(txQueue.front());
txQueue.pop();
}
break;
case WaitDataPdu:
Trace::out("\t- wait data pdu");
getThread()->scheduleTimeout(ConnectionPduMaxTimeout::Id, CONNECTION_PDU_MAX_TIMEOUT, this);
break;
case ProcessDataPdu:
Trace::out("\t- process data pdu");
pushEvent( new XFNullTransition( WaitNullTransition::Id ) );
break;
case CloseConnection:
Trace::out("\t- close connection");
break;
case WaitForNextConnectionEvent:
Trace::out("\t- wait for connection");
getThread()->scheduleTimeout(ConnectionIntervalTimeout::Id, CONNECTION_INTERVAL_TIMEOUT, this);
break;
case EnableTransceiver:
Trace::out("\t- enable transceiver");
break;
default:
Trace::out("\t- undefined state error");
break;
}
}
示例8: main
int main(void)
{
freopen("holstein.in", "r", stdin);
freopen("holstein.out", "w", stdout);
cin >> V;
for (int i=1;i<=V;i++) cin >> v[i];
cin >> G;
for (int i=1;i<=G;i++)
for (int j=1;j<=V;j++)
cin >> g[i][j];
for (int i=1;i<=G;i++)
{
bool flag=true;
for (int j=1;j<=V;j++)
{
if (g[i][j]<v[j])
{
flag=false;
break;
}
}
if (flag==true)
{
cout << 1 << " " << i << endl;
return 0;
}
}
State t;
for (int i=1;i<=G;i++)
t.s[i]=false;
for (int i=1;i<=V;i++)
t.c[i]=0;
search(t, G);
State s=t;
int minimum=G+1;
while(!q.empty())
{
State st=q.front();
q.pop();
int leng=length(st);
if (leng!=0)
{
if (leng<minimum)
{
minimum=leng;
s=st;
}
}
}
int path[16]={0};
int sum=0;
for (int k=1;k<=G;k++)
if (s.s[k]==true)
{
sum++;
path[sum]=k;
}
cout << sum << " ";
for (int k=1;k<sum;k++)
cout << path[k] << " ";
cout << path[sum] << endl;
return 0;
}
示例9: phasepoints
void phasepoints(Parameter& xi, Parameters params, queue<Point>& points, vector<PointResults>& pres, progress_display& progress) {
int ndim = 2 * L * dim;
boost::random::mt19937 xrng;
boost::random::uniform_real_distribution<> xuni(0, 1);
vector<double> xrand(ndim);
for (int i = 0; i < ndim; i++) {
xrand[i] = xuni(xrng);
}
vector<double> x(ndim);
vector<complex<double>*> f(L);
for (int i = 0; i < L; i++) {
f[i] = reinterpret_cast<complex<double>*> (&x[2 * i * dim]);
}
vector<double> U(L), J(L), dU(L);
vector<double> x0(ndim), xth(ndim), x2th(ndim);
vector<complex<double>*> f0(L);
for (int i = 0; i < L; i++) {
f0[i] = reinterpret_cast<complex<double>*> (&x0[2 * i * dim]);
}
vector<vector<double> > fabs(L, vector<double>(dim));
vector<double> fn0(L);
vector<double> fmax(L);
vector<double> norms(L);
double theta = params.theta;
double scale = 1;
GroundStateProblem* prob;
opt lopt(LD_LBFGS, ndim);
opt gopt(GN_DIRECT, ndim);
// energyprob eprob(ndim);
// pagmo::algorithm::de_1220 algo(100);
// int npop = 20;
{
boost::mutex::scoped_lock lock(problem_mutex);
prob = new GroundStateProblem();
lopt.set_lower_bounds(-1);
lopt.set_upper_bounds(1);
lopt.set_min_objective(energyfunc, prob);
gopt.set_lower_bounds(-1);
gopt.set_upper_bounds(1.1);
gopt.set_min_objective(energyfunc, prob);
gopt.set_maxtime(120);
// lopt.set_maxtime(120);
// lopt.set_ftol_abs(1e-17);
// lopt.set_ftol_rel(1e-17);
// eprob.setProblem(prob);
}
for (;;) {
Point point;
{
boost::mutex::scoped_lock lock(points_mutex);
if (points.empty()) {
break;
}
point = points.front();
points.pop();
}
PointResults pointRes;
pointRes.W = point.x;
pointRes.mu = point.mu;
vector<double> W(L);
for (int i = 0; i < L; i++) {
W[i] = xi[i] * point.x;
}
double U0 = 1 / scale;
// for (int i = 0; i < L; i++) {
// U[i] = UW(W[i]) / UW(point.x) / scale;
// U0 += U[i] / L;
// }
for (int i = 0; i < L; i++) {
U[i] = UW(W[i]) / UW(point.x) / scale;
// U[i] = 1 / scale;
dU[i] = U[i] - U0;
J[i] = JWij(W[i], W[mod(i + 1)]) / UW(point.x) / scale;
// J[i] = JWij(point.x, point.x) / UW(point.x) / scale;
}
pointRes.Ux = UW(point.x);
pointRes.Jx = JWij(point.x, point.x);
pointRes.J = J;
pointRes.U = U;
// fill(x0.begin(), x0.end(), 0.5);
// fill(xth.begin(), xth.end(), 0.5);
// fill(x2th.begin(), x2th.end(), 0.5);
// generate(x0.begin(), x0.end(), randx);
//.........这里部分代码省略.........
示例10: testcase
void testcase()
{
while(!q.empty())
{
q.pop();
}
memset(dp, -1, sizeof(dp));
target_x = start_x = target_y = start_y = -1;
for(int i = 0; i < M; i++)
{
for(int j = 0; j < N; j++)
{
scanf("%c", &board[j][i]);
if(board[j][i] == 'S')
{
start_x = j;
start_y = i;
board[j][i] = '.';
}
else if(board[j][i] == 'T')
{
target_x = j;
target_y = i;
board[j][i] = '.';
}
// printf("%c", board[j][i]);
}
scanf("\n");
// printf("\n");
}
if(start_x == -1 || start_y == -1 || target_x == -1 || target_y == -1)
{
printf("destination not reachable\n");
return;
}
state tmp;
tmp.x = start_x;
tmp.y = start_y;
tmp.facing = 0;
tmp.color = 0;
tmp.time = 0;
q.push(tmp);
while(!q.empty())
{
state f = q.front();
// printf("S x%d y%d f%d c%d t%d\n", f.x, f.y, f.facing, f.color, f.time);
q.pop();
f.time++;
// turn left
TURN_LEFT(f);
if(!EXISTS(f))
{
SETDP(f);
q.push(f);
}
// turn right
TURN_RIGHT(f);
TURN_RIGHT(f);
if(!EXISTS(f))
{
SETDP(f);
q.push(f);
}
TURN_LEFT(f);
// move fwd
switch(f.facing)
{
// N
case 0:
f.y--;
break;
// E
case 1:
f.x++;
break;
// S
case 2:
f.y++;
break;
// W
case 3:
f.x--;
break;
}
CYCLE_COLOR(f);
// check if we can move fwd
if(f.x >= 0 && f.x < N && f.y >= 0 && f.y < M && board[f.x][f.y] != '#')
{
if(f.x == target_x && f.y == target_y && f.color == 0)
{
// printf("S x%d y%d f%d c%d t%d\n", f.x, f.y, f.facing, f.color, f.time);
printf("minimum time = %d sec\n", f.time);
return;
}
if(!EXISTS(f))
{
SETDP(f);
q.push(f);
}
//.........这里部分代码省略.........
示例11: while
void QueueSequence::queue2_sequence(int queue2_element1,int queue2_element2){
int step1_counter=0,swap=0,step2_counter,step3_counter,manage_queue2;
step3_counter=queue2_operator1.size();
while(!(queue2_operator1.front()==queue2_element1 || queue2_operator1.front()==queue2_element2))
{
exchange_temp3=queue2_operator1.front();
queue2_operator1.pop();
queue2_operator1.push(exchange_temp3);
step1_counter++;
}
exchange_temp3=queue2_operator1.front();
queue2_operator1.pop();
queue2_operator2.push(exchange_temp3);
swap=1;
while(!(queue2_operator1.front()==queue2_element1 || queue2_operator1.front()==queue2_element2))
{
if(swap==1){
queue2_operator3.push(queue2_operator1.front());
queue2_operator1.pop();
while(!queue2_operator2.empty()){
queue2_operator3.push(queue2_operator2.front());
queue2_operator2.pop();
}
swap=0;
}
else{
queue2_operator2.push(queue2_operator1.front());
queue2_operator1.pop();
while(!queue2_operator3.empty()){
queue2_operator2.push(queue2_operator3.front());
queue2_operator3.pop();
}
swap=1;
}
}
if(swap==1){
queue2_operator3.push(queue2_operator1.front());
queue2_operator1.pop();
while(!queue2_operator2.empty()){
queue2_operator3.push(queue2_operator2.front());
queue2_operator2.pop();
}
step2_counter=queue2_operator3.size();
while(!queue2_operator3.empty()){
queue2_operator1.push(queue2_operator3.front());
queue2_operator3.pop();
}
}
else{
queue2_operator2.push(queue2_operator1.front());
queue2_operator1.pop();
while(!queue2_operator3.empty()){
queue2_operator2.push(queue2_operator3.front());
queue2_operator3.pop();
}
step2_counter=queue2_operator2.size();
while(!queue2_operator2.empty()){
queue2_operator1.push(queue2_operator2.front());
queue2_operator2.pop();
}
}
manage_queue2=step3_counter-(step2_counter+step1_counter);
while(manage_queue2--)
{
exchange_temp3=queue2_operator1.front();
queue2_operator1.pop();
queue2_operator1.push(exchange_temp3);
}
}
示例12: Insert
Relation* Insert(vector<string> &words, string &line, SchemaManager &schema_manager, MainMemory &mem){
Relation* relation_ptr = schema_manager.getRelation(words[2]);
vector<string>::iterator it = find(words.begin(), words.end(), "SELECT");
// no select
if (it == words.end()){
// get insert vals
vector<string> content = splitBy(line, "()");
vector<string> fields = splitBy(content[1], ", ");
vector<string> vals = splitBy(content[3], ",");
//preProcess(vector<string>(1, words[2]), fields, schema_manager);
preProcess(vector<string>(1, words[2]), vals, schema_manager);
assert(fields.size() == vals.size());
Tuple tuple = relation_ptr->createTuple();
// standard insert doesn't have table names
vector<string> col_names = nakedFieldNames(relation_ptr);
// comparing
for (int i = 0; i < fields.size(); i++){
for (int j = 0; j < col_names.size(); j++){
// this is a match
if (fields[i] == col_names[j]){
if (tuple.getSchema().getFieldType(j) == INT){
tuple.setField(j, atoi(vals[i].c_str()));
}
else{
tuple.setField(j, vals[i]);
}
break;
}
}
}
appendTupleToRelation(relation_ptr, mem, tuple);
}
// with SELECT
else{
vector<string> SFW(it, words.end());
Relation* new_relation = Select(SFW, schema_manager, mem);
assert(new_relation);
vector<string> new_field_names = nakedFieldNames(new_relation);
vector<string> field_names = nakedFieldNames(relation_ptr);
// mapping: index of new_field_names to field_names
vector<int> mapping(new_field_names.size(), -1);
for (int i = 0; i < new_field_names.size(); i++){
for (int j = 0; j < field_names.size(); j++){
if (new_field_names[i] == field_names[j]){
mapping[i] = j;
break;
}
}
}
int new_field_size = new_relation->getSchema().getNumOfFields();
// warning: new_relation and relation_ptr might be the same!
// get all tuples from the new_relation in one run
vector<Tuple> new_tuples;
for (int i = 0; i < new_relation->getNumOfBlocks(); i++){
assert(!free_blocks.empty());
int memory_block_index = free_blocks.front();
free_blocks.pop();
// read the relation block by block
new_relation->getBlock(i, memory_block_index);
Block* block_ptr = mem.getBlock(memory_block_index);
assert(block_ptr);
vector<Tuple> block_tuples = block_ptr->getTuples();
new_tuples.insert(new_tuples.end(), block_tuples.begin(), block_tuples.end());
if(new_tuples.empty()){
cerr<<"Warning: Insert from SFW, No tuples in the current mem block!"<<endl;
}
free_blocks.push(memory_block_index);
}
for (int j = 0; j < new_tuples.size(); j++){
Tuple tuple = relation_ptr->createTuple();
for (int k = 0; k < new_field_size; k++){
if (mapping[k] != -1){
int idx = mapping[k];
assert(idx < relation_ptr->getSchema().getNumOfFields() && idx >= 0);
if (tuple.getSchema().getFieldType(idx) == INT){
int val = new_tuples[j].getField(k).integer;
tuple.setField(field_names[idx], val);
}
else{
string *str = new_tuples[j].getField(k).str;
tuple.setField(field_names[idx], *str);
}
}
}
appendTupleToRelation(relation_ptr, mem, tuple);
}
cout<<*relation_ptr<<endl;
}
//.........这里部分代码省略.........
示例13: TIMERSTART
bool CvTest3DPoseEstimate::testVideo4OneFrame(queue<StereoFrame> inputImageQueue,
FrameSeq& frameSeq, CamTracker& tracker)
{
bool insertNewKeyFrame = false;
TIMERSTART(Total);
// currFrame is a reference to frameSeq.mCurrentFrame;
PoseEstFrameEntry*& currFrame = frameSeq.mCurrentFrame;
bool gotCurrFrame = false;
bool stop = false;
if (frameSeq.mNextFrame.get()){
// do not need to load new images nor compute the key points again
frameSeq.mCurrentFrame = frameSeq.mNextFrame.release();
gotCurrFrame = true;
} else {
int numWaits;
// wait at most for 30 seconds
const int maxNumWaits = 30*30;
for (numWaits=0; numWaits<maxNumWaits && inputImageQueue.size()==0; numWaits++){
// wait for 33 milliseconds
usleep(33000);
}
if (numWaits>=maxNumWaits) {
stop = true;
} else {
// process the next stereo pair of images.
StereoFrame stereoFrame = inputImageQueue.front();
if (stereoFrame.mFrameIndex == -1) {
// done
stop = true;
gotCurrFrame = false;
} else {
currFrame = new PoseEstFrameEntry(stereoFrame.mFrameIndex);
currFrame->mImage = stereoFrame.mImage;
currFrame->mRightImage = stereoFrame.mRightImage;
currFrame->mDispMap = stereoFrame.mDispMap;
// compute disparity map
TIMERSTART2(DisparityMap);
currFrame->mDispMap = new WImageBuffer1_16s(
currFrame->mImage->Width(), currFrame->mImage->Height());
tracker.getPoseEstimator()->getDisparityMap(*currFrame->mImage,
*currFrame->mRightImage, *currFrame->mDispMap);
TIMEREND2(DisparityMap);
#if SAVEDISPMAP
{
char dispfilename[256];
char dispname[256];
sprintf(dispfilename, "Output/indoor1/dispmap-%04d.xml",
currFrame->mFrameIndex);
sprintf(dispname, "dispmap-%04d.xml", currFrame->mFrameIndex);
cvSave(dispfilename, currFrame->mDispMap, dispname, "disparity map 16s");
}
#endif
// counting how many frames we have processed
frameSeq.mNumFrames++;
TIMERSTART2(FeaturePoint);
tracker.goodFeaturesToTrack(*currFrame->mImage, currFrame->mDispMap,
currFrame->mKeypoints);
TIMEREND2(FeaturePoint);
// if (mVisualizer) mVisualizer->drawDispMap(*currFrame);
}
inputImageQueue.pop();
}
}
KeyFramingDecision kfd = KeyFrameBackTrack;
if (stop == false) {
if (frameSeq.mNumFrames==1) {
// First frame ever, do not need to do anything more.
frameSeq.mStartFrameIndex = currFrame->mFrameIndex;
kfd = KeyFrameUse;
} else {
//
// match the good feature points between this iteration and last key frame
//
vector<pair<CvPoint3D64f, CvPoint3D64f> > trackablePairs;
if (currFrame->mTrackableIndexPairs == NULL) {
currFrame->mTrackableIndexPairs = new vector<pair<int, int> >();
} else {
currFrame->mTrackableIndexPairs->clear();
}
tracker.matchKeypoints(&trackablePairs, currFrame->mTrackableIndexPairs);
assert(currFrame->mTrackableIndexPairs->size() == trackablePairs.size());
#ifdef DEBUG
cout << "Num of trackable pairs for pose estimate: "<<trackablePairs.size() << endl;
#endif
// if applicable, pass a reference of the current frame for visualization
// if (mVisualizer) mVisualizer->drawKeypoints(*getLastKeyFrame(), *currFrame, trackablePairs);
if (currFrame->mNumTrackablePairs< defMinNumTrackablePairs) {
#ifdef DEBUG
cout << "Too few trackable pairs" <<endl;
#endif
// shall backtrack
//.........这里部分代码省略.........
示例14: popo
void popo(queue<int>& from, queue<int>&to) {
while(!from.empty()) {
to.push(from.front());
from.pop();
}
}
示例15: main
int main()
{
int tcase = 0;
cin >> nNodes;
while(nNodes != 0)
{
for(int i = 1; i <= nNodes; ++i)
adjList[i].clear();
memset(adjMat, 0, sizeof(adjMat));
cin >> start >> sink >> nEdges;
int na, nb, cap;
for(int e = 0; e < nEdges; ++e)
{
scanf("%i %i %i", &na, &nb, &cap);
adjMat[na][nb] += cap;
adjMat[nb][na] += cap;
adjList[na].insert(nb);
adjList[nb].insert(na);
}
maxFlow = 0;
while(true)
{
while(!bfsQ.empty())
bfsQ.pop();
for(int i = 1; i <= nNodes; ++i)
dist[i] = INF;
memset(parent, 0, sizeof(parent));
tFlow = 0;
bfsQ.push(start);
dist[start] = 0;
while(!bfsQ.empty())
{
int tn = bfsQ.front();
bfsQ.pop();
if(tn == sink)
break;
for(vi_it e = adjList[tn].begin();
e != adjList[tn].end(); ++e)
{
if(adjMat[tn][*e] > 0 && dist[*e] == INF)
{
dist[*e] = dist[tn] + 1;
bfsQ.push(*e);
parent[*e] = tn;
}
}
}
augmentPath(sink, INF);
if(tFlow == 0)
break;
maxFlow += tFlow;
}
printf("Network %i\nThe bandwidth is %i.\n\n", ++tcase, maxFlow);
cin >> nNodes;
}
return 0;
}