当前位置: 首页>>代码示例>>C++>>正文


C++ vector::erase方法代码示例

本文整理汇总了C++中typenamestd::vector::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::erase方法的具体用法?C++ vector::erase怎么用?C++ vector::erase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在typenamestd::vector的用法示例。


在下文中一共展示了vector::erase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock


//.........这里部分代码省略.........
  int  nout = 0;
  while ( nout > -1 && !exitServiceFunction && serviceThread->threadRunning() ) {

    eos = false;
    nout = _forecastAndProcess( eos, istreams, ostreams );
    if ( nout > -1  ) {

      // we chunked on data so move read pointer..
      istream = istreams.begin();
      for ( ; istream != istreams.end(); istream++ ) {
	int idx=std::distance( istreams.begin(), istream );
	// if we processed data for this stream
	if ( _input_ready[idx] ) {
	  size_t nitems = 0;
	  try {
	    nitems = gr_sptr->nitems_read( idx );
	  }
	  catch(...){}
      
	  istream->consume( nitems );
	  LOG_TRACE( copy_octet_base, " CONSUME READ DATA  ITEMS/REMAIN " << nitems << "/" << istream->nitems());
	}

      }
      gr_sptr->reset_read_index();
    }

    // check for not enough data return
    if ( nout == -1 ) {

      // check for  end of stream
      istream = istreams.begin();
      for ( ; istream != istreams.end() ; istream++) if ( istream->eos() ) eos=true;

      if ( eos ) {
        LOG_TRACE(  copy_octet_base, " DATA NOT READY, EOS:" << eos );
	_forecastAndProcess( eos, istreams, ostreams);
      }

      exitServiceFunction = true;
    }

  }

  if ( eos ) {

    istream = istreams.begin();
    for ( ; istream != istreams.end() ; ) {

      int idx=std::distance( istreams.begin(), istream );
      if (  istream->eos() || eos == true ) {
	LOG_DEBUG( copy_octet_base, " CLOSING INPUT STREAM IDX:" << idx );
         istream->close();
         //
         // if we are variable input list of input streams and fixed output...... humm
         //
         if ( gr_sptr->get_max_input_streams() == -1 ) {
            LOG_DEBUG( copy_octet_base, " REMOVE VARIABLE INPUT STREAM IDX:" << idx );
            istream=istreams.erase( istream );
            gr_sptr->remove_read_index( idx );

	    // if output is variable then close the corresponding output stream
	    if ( gr_sptr->get_max_output_streams() == -1 && outPorts.size() == 1 ) {
	       ostream = ostreams.begin();
	       for ( int i=0; ostream != ostreams.end(); i++, ostream++) {
	          if ( i == idx ) {
                     LOG_DEBUG( copy_octet_base, " REMOVE VARIABLE OUTPUT STREAM IDX:" << idx );
	             ostream=ostreams.erase(ostream);
		     break;
                  }
               }
            }
         }
         else {
            istream++;
         }
      }

    }

    // close remaining output streams
    ostream = ostreams.begin();
    for ( ; eos && ostream != ostreams.end(); ostream++ ) ostream->close();

  }

  //
  // set the read pointers of the GNU Radio Block to start at the beginning of the 
  // supplied buffers
  //
  gr_sptr->reset_read_index();

  LOG_TRACE( copy_octet_base, " END OF TRANSFORM SERVICE FUNCTION....." << noutput_items );

  if ( nout == -1 && eos == false )
    return NOOP;    
  else
    return NORMAL;

}
开发者ID:VenturaSolutionsInc,项目名称:integration-gnuhawk,代码行数:101,代码来源:copy_octet_base.cpp


注:本文中的typenamestd::vector::erase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。