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


C++ list::resize方法代码示例

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


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

示例1: FilterTargets

            void FilterTargets(std::list<WorldObject*>& targets)
            {
                targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster()));

                if (targets.size() > 4)
                    targets.resize(4);

                while (targets.size() > 2)
                    targets.pop_front();
            }
开发者ID:Anonymus123,项目名称:AtomicCore-3.3.5a,代码行数:10,代码来源:boss_rotface.cpp

示例2: load

  //! Loading for std::list
  template <class Archive, class T, class A> inline
  void load( Archive & ar, std::list<T, A> & list )
  {
    size_type size;
    ar( make_size_tag( size ) );

    list.resize( static_cast<size_t>( size ) );

    for( auto & i : list )
      ar( i );
  }
开发者ID:KnowSheet,项目名称:3party,代码行数:12,代码来源:list.hpp

示例3: CEREAL_LOAD_FUNCTION_NAME

  //! Loading for std::list
  template <class Archive, class T, class A> inline
  void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::list<T, A> & list )
  {
    size_type size;
    ar( make_size_tag( size ) );

    list.resize( static_cast<size_t>( size ) );

    for( auto & i : list )
      ar( i );
  }
开发者ID:deathbaba,项目名称:Alohalytics,代码行数:12,代码来源:list.hpp

示例4: FilterTargets

        void FilterTargets(std::list<WorldObject*>& targets)
        {
            // get 2 targets except 2 nearest
            targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster()));

            // .resize() runs pop_back();
            if (targets.size() > 5)
                targets.resize(5);

            while (targets.size() > 2)
                targets.pop_front();
        }
开发者ID:xjose93,项目名称:TrinityCore,代码行数:12,代码来源:boss_rotface.cpp

示例5: FilterTargets

            void FilterTargets(std::list<WorldObject*>& targets)
            {
                targets.remove_if(RaidCheck(GetCaster()));

                uint32 const maxTargets = GetCaster()->HasAura(SPELL_PRIEST_GLYPH_OF_CIRCLE_OF_HEALING) ? 6 : 5; // Glyph of Circle of Healing

                if (targets.size() > maxTargets)
                {
                    targets.sort(Trinity::HealthPctOrderPred());
                    targets.resize(maxTargets);
                }
            }
开发者ID:DSlayerMan,项目名称:ArkCORE-NG,代码行数:12,代码来源:spell_priest.cpp

示例6: find_range

int TwoSum::find_range(int lower, int upper) {
    int count = 0;
    numbers_to_check.resize(upper-lower);
    for (int i=lower; i<= upper; i++ ) {
	numbers_to_check.push_back(i);
    };
    for( auto it = numbers.begin(); it != numbers.end(); ++it ) {
	if( find_sum(it->first) ) { 
	    ++count; 
	};
    };	
    return count;
};
开发者ID:qwwqwwq,项目名称:coursera_algo_hw,代码行数:13,代码来源:2sum.cpp

示例7: FilterTargets

            void FilterTargets(std::list<WorldObject*>& targets)
            {
                targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster()));

                // Selects 5 nearest dummies, including the caster
                // .resize() runs pop_back();
                if (targets.size() > 5)
                    targets.resize(5);

                // Selects 2 farthest ones to cast a spell
                while (targets.size() > 2)
                    targets.pop_front();
            }
开发者ID:mynew,项目名称:Core,代码行数:13,代码来源:boss_rotface.cpp

示例8: FilterTargets

            void FilterTargets(std::list<WorldObject*>& targets)
            {
                targets.remove_if(RaidCheck(GetCaster()));

                uint32 const maxTargets = uint32(GetSpellInfo()->Effects[EFFECT_2].CalcValue(GetCaster()));

                if (targets.size() > maxTargets)
                {
                    targets.sort(Trinity::HealthPctOrderPred());
                    targets.resize(maxTargets);
                }

                _targets = targets;
            }
开发者ID:AwkwardDev,项目名称:TinyCore,代码行数:14,代码来源:spell_druid.cpp

示例9: FilterTargets

 void FilterTargets(std::list<WorldObject*>& targets)
 {
     if (InstanceMap* instance = GetCaster()->GetMap()->ToInstanceMap())
     {
         if (InstanceScript* const script = instance->GetInstanceScript())
         {
             if (GameObject* go = ObjectAccessor::GetGameObject(*GetCaster(), script->GetData64(DATA_ANHUUR_DOOR)))
             {
                 targets.remove_if(Trinity::HeightDifferenceCheck(go, 5.0f, false));
                 targets.remove(GetCaster());
                 targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster()));
                 targets.resize(2);
             }
         }
     }
 }
开发者ID:GlassFace,项目名称:Mist-Eria-Core510,代码行数:16,代码来源:boss_temple_guardian_anhuur.cpp

示例10: find

 /**
  * @param[in] p position.
  * @param[in] num a number of node which you want
  * @param[out] node result.
  * @param[in] radius a radius of initial sphere.
  */
 void find(const T p, const size_t num, std::list<T>& node, double radius = 0.1) {
         if (_numElement < num) {
                 std::cerr<<"Error. you give larger number"<<std::endl;
                 return ;
         }
         const double base = pow(static_cast<double>(num), 0.3333f);
         node.clear();
         while ( node.size() < num ) {
                 this->find(p, radius, node, false);
                 if (node.size() == 0) radius *= 2;
                 else  radius *= static_cast<double>(base / pow(node.size(), 0.3333));
         }
         node.sort(less_vec_length(p));
         node.resize(num);
         return;
 }
开发者ID:daikiyamanaka,项目名称:denviewer,代码行数:22,代码来源:Kdtree.hpp

示例11: get_subject

 static bool get_subject(std::string& s, std::list<std::string>& patterns, std::string& error) {
   patterns.resize(0);
   std::string::size_type f;
   std::string str;
   f = find(s.c_str(), s.length(), subjectname.c_str(), subjectname.length());
   if(f == std::string::npos) {
     error += "Missing subjects token in namespaces policy\n";
     return false;
   }
   str = s.substr(f + subjectname.length());
   std::string subject;
   get_word(str,subject);
   if(subject.empty()) {
     error += "Missing subjects in namespaces policy\n";
     return false;
   }
   patterns.push_back(subject);
   return true;
 }
开发者ID:ic-hep,项目名称:emi3,代码行数:19,代码来源:namespacespolicy.cpp

示例12: exec

//=================================================================================================
void DCmdFindID::exec(const DPreprocessor::DS_Command* pContext)
{
	DStaticAssert(D_PREPROCESSOR_NBPARAMS >= 2);
	DAssertMsg(pContext->nbParameters == 2, "Invalid parameter in script file.");
	
	const std::list<DString>& fileList = DCmdFindFile::getFileList();
	const char* pBeginMarkup = pContext->aParameters[0];
	const char* pEndMarkup = pContext->aParameters[1];
	if(!*pEndMarkup)
		pEndMarkup = "\r\n";
	u32 beginMarkupLength = DStrLen(pBeginMarkup);
	u32 endMarkupLength = DStrLen(pEndMarkup);
	
	// Parcours des fichiers
	for(std::list<DString>::const_iterator it = fileList.begin(); it != fileList.end(); it++)
	{
		// Lecture du fichier
		char* pFileBuffer = static_cast<char*>(DLoadFile(it->getCStr()));
		
		// Recherche de la balise de début
		const char* pBegin = DStrStr(pFileBuffer, pBeginMarkup);
		while(pBegin)
		{
			pBegin += beginMarkupLength;
			
			// Recherche de la balise de fin
			const char* pEnd = DStrStr(pBegin, pEndMarkup);
			if(pEnd)
			{
				g_ResultList.resize(g_ResultList.size() + 1);
				DS_Result* pResult = &g_ResultList.back();
				DStrNCpy(pResult->ID.getCStr(), D_STRING_LENGTH, pBegin, pEnd - pBegin);
				pResult->filePath = it->getCStr();
				pResult->position = static_cast<u32>(pBegin - pFileBuffer);
			}
			
			pBegin = DStrStr(pEnd + endMarkupLength, pBeginMarkup);
		}
		
		// Destruction du buffer de fichier
		DUnloadFile(pFileBuffer);
	}
}
开发者ID:SeungMinChoi,项目名称:ejcharpenay,代码行数:44,代码来源:DCmdFindID.cpp

示例13: Import

int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
              TrackHolders &outTracks,
              Tags *tags)
{
   outTracks.clear();

   CreateProgress();

   // Remove stream contexts which are not marked for importing and adjust mScs and mNumStreams accordingly
   const auto scs = mScs->get();
   for (int i = 0; i < mNumStreams;)
   {
      if (!scs[i]->m_use)
      {
         for (int j = i; j < mNumStreams - 1; j++)
         {
            scs[j] = std::move(scs[j+1]);
         }
         mNumStreams--;
      }
      else i++;
   }

   mChannels.resize(mNumStreams);

   int s = -1;
   for (auto &stream : mChannels)
   {
      ++s;

      auto sc = scs[s].get();
      switch (sc->m_stream->codec->sample_fmt)
      {
         case AV_SAMPLE_FMT_U8:
         case AV_SAMPLE_FMT_S16:
         case AV_SAMPLE_FMT_U8P:
         case AV_SAMPLE_FMT_S16P:
            sc->m_osamplesize = sizeof(int16_t);
            sc->m_osamplefmt = int16Sample;
         break;
         default:
            sc->m_osamplesize = sizeof(float);
            sc->m_osamplefmt = floatSample;
         break;
      }

      // There is a possibility that number of channels will change over time, but we do not have WaveTracks for NEW channels. Remember the number of channels and stick to it.
      sc->m_initialchannels = sc->m_stream->codec->channels;
      stream.resize(sc->m_stream->codec->channels);
      int c = -1;
      for (auto &channel : stream)
      {
         ++c;

         channel = trackFactory->NewWaveTrack(sc->m_osamplefmt, sc->m_stream->codec->sample_rate);

         if (sc->m_stream->codec->channels == 2)
         {
            switch (c)
            {
            case 0:
               channel->SetChannel(Track::LeftChannel);
               channel->SetLinked(true);
               break;
            case 1:
               channel->SetChannel(Track::RightChannel);
               break;
            }
         }
         else
         {
            channel->SetChannel(Track::MonoChannel);
         }
      }
   }

   // Handles the start_time by creating silence. This may or may not be correct.
   // There is a possibility that we should ignore first N milliseconds of audio instead. I do not know.
   /// TODO: Nag FFmpeg devs about start_time until they finally say WHAT is this and HOW to handle it.
   s = -1;
   for (auto &stream : mChannels)
   {
      ++s;

      int64_t stream_delay = 0;
      auto sc = scs[s].get();
      if (sc->m_stream->start_time != int64_t(AV_NOPTS_VALUE) && sc->m_stream->start_time > 0)
      {
         stream_delay = sc->m_stream->start_time;
         wxLogDebug(wxT("Stream %d start_time = %lld, that would be %f milliseconds."), s, (long long) sc->m_stream->start_time, double(sc->m_stream->start_time)/AV_TIME_BASE*1000);
      }
      if (stream_delay != 0)
      {
         int c = -1;
         for (auto &channel : stream)
         {
            ++c;

            WaveTrack *t = channel.get();
            t->InsertSilence(0,double(stream_delay)/AV_TIME_BASE);
//.........这里部分代码省略.........
开发者ID:aeve,项目名称:audacity,代码行数:101,代码来源:ImportFFmpeg.cpp

示例14: claim_file_hook

/// Called by gold to see whether this file is one that our plugin can handle.
/// We'll try to open it and register all the symbols with add_symbol if
/// possible.
static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
                                        int *claimed) {
  LLVMContext Context;
  MemoryBufferRef BufferRef;
  std::unique_ptr<MemoryBuffer> Buffer;
  if (get_view) {
    const void *view;
    if (get_view(file->handle, &view) != LDPS_OK) {
      message(LDPL_ERROR, "Failed to get a view of %s", file->name);
      return LDPS_ERR;
    }
    BufferRef =
        MemoryBufferRef(StringRef((const char *)view, file->filesize), "");
  } else {
    int64_t offset = 0;
    // Gold has found what might be IR part-way inside of a file, such as
    // an .a archive.
    if (file->offset) {
      offset = file->offset;
    }
    ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
        MemoryBuffer::getOpenFileSlice(file->fd, file->name, file->filesize,
                                       offset);
    if (std::error_code EC = BufferOrErr.getError()) {
      message(LDPL_ERROR, EC.message().c_str());
      return LDPS_ERR;
    }
    Buffer = std::move(BufferOrErr.get());
    BufferRef = Buffer->getMemBufferRef();
  }

  Context.setDiagnosticHandler(diagnosticHandler);
  ErrorOr<std::unique_ptr<object::IRObjectFile>> ObjOrErr =
      object::IRObjectFile::create(BufferRef, Context);
  std::error_code EC = ObjOrErr.getError();
  if (EC == object::object_error::invalid_file_type ||
      EC == object::object_error::bitcode_section_not_found)
    return LDPS_OK;

  *claimed = 1;

  if (EC) {
    message(LDPL_ERROR, "LLVM gold plugin has failed to create LTO module: %s",
            EC.message().c_str());
    return LDPS_ERR;
  }
  std::unique_ptr<object::IRObjectFile> Obj = std::move(*ObjOrErr);

  Modules.resize(Modules.size() + 1);
  claimed_file &cf = Modules.back();

  cf.handle = file->handle;

  // If we are doing ThinLTO compilation, don't need to process the symbols.
  // Later we simply build a combined index file after all files are claimed.
  if (options::thinlto) return LDPS_OK;

  for (auto &Sym : Obj->symbols()) {
    uint32_t Symflags = Sym.getFlags();
    if (shouldSkip(Symflags))
      continue;

    cf.syms.push_back(ld_plugin_symbol());
    ld_plugin_symbol &sym = cf.syms.back();
    sym.version = nullptr;

    SmallString<64> Name;
    {
      raw_svector_ostream OS(Name);
      Sym.printName(OS);
    }
    sym.name = strdup(Name.c_str());

    const GlobalValue *GV = Obj->getSymbolGV(Sym.getRawDataRefImpl());

    sym.visibility = LDPV_DEFAULT;
    if (GV) {
      switch (GV->getVisibility()) {
      case GlobalValue::DefaultVisibility:
        sym.visibility = LDPV_DEFAULT;
        break;
      case GlobalValue::HiddenVisibility:
        sym.visibility = LDPV_HIDDEN;
        break;
      case GlobalValue::ProtectedVisibility:
        sym.visibility = LDPV_PROTECTED;
        break;
      }
    }

    if (Symflags & object::BasicSymbolRef::SF_Undefined) {
      sym.def = LDPK_UNDEF;
      if (GV && GV->hasExternalWeakLinkage())
        sym.def = LDPK_WEAKUNDEF;
    } else {
      sym.def = LDPK_DEF;
      if (GV) {
//.........这里部分代码省略.........
开发者ID:nightwishud,项目名称:accmut,代码行数:101,代码来源:gold-plugin.cpp

示例15: GetActiveWindowsList

void NxScreenManager::GetActiveWindowsList( std::list< NxScreen *> & ScreenList )
{
	ScreenList.resize(MonitorListActive.size());
	std::copy(MonitorListActive.begin(),MonitorListActive.end(),ScreenList.begin());
}
开发者ID:nxgraphics,项目名称:NxGraphics,代码行数:5,代码来源:NxWindowManager.cpp


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