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


C++ set::empty方法代码示例

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


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

示例1: isMasked

    /**
     * @return True if the data should be deleted.
     */
    bool MaskWorkspace::isMasked(const std::set<detid_t> &detectorIDs) const
    {
      if (detectorIDs.empty())
      {
        return false;
      }

      bool masked(true);
      for (std::set<detid_t>::const_iterator it = detectorIDs.begin(); it != detectorIDs.end(); ++it)
      {
        if (!this->isMasked(*it))
        {
          masked = false;
          break; // allows space for a debug print statement
        }
      }
      return masked;
    }
开发者ID:jkrueger1,项目名称:mantid,代码行数:21,代码来源:MaskWorkspace.cpp

示例2: FillDetails

void CFileItemHandler::FillDetails(const ISerializable *info, const CFileItemPtr &item, std::set<std::string> &fields, CVariant &result, CThumbLoader *thumbLoader /* = NULL */)
{
  if (info == NULL || fields.empty())
    return;

  CVariant serialization;
  info->Serialize(serialization);

  bool fetchedArt = false;

  std::set<std::string> originalFields = fields;

  for (std::set<std::string>::const_iterator fieldIt = originalFields.begin(); fieldIt != originalFields.end(); ++fieldIt)
  {
    if (GetField(*fieldIt, serialization, item, result, fetchedArt, thumbLoader) && result.isMember(*fieldIt) && !result[*fieldIt].empty())
      fields.erase(*fieldIt);
  }
}
开发者ID:Dreamer-4pda,项目名称:kodi-cmake,代码行数:18,代码来源:FileItemHandler.cpp

示例3:

std::set<T> MonsterGenerator::get_set_from_tags(std::set<std::string> tags,
                                                std::map<std::string, T> conversion_map, T fallback)
{
    std::set<T> ret;

    if (!tags.empty()){
        for (std::set<std::string>::iterator it = tags.begin(); it != tags.end(); ++it){
            if (conversion_map.find(*it) != conversion_map.end()){
                ret.insert(conversion_map[*it]);
            }
        }
    }
    if (ret.empty()){
        ret.insert(fallback);
    }

    return ret;
}
开发者ID:HolyHemperor,项目名称:Cataclysm-DDA,代码行数:18,代码来源:monstergenerator.cpp

示例4:

std::set<T> MonsterGenerator::get_set_from_tags(std::set<std::string> tags,
        std::map<std::string, T> conversion_map, T fallback)
{
    std::set<T> ret;

    if (!tags.empty()) {
        for( const auto &tag : tags ) {
            if( conversion_map.find( tag ) != conversion_map.end() ) {
                ret.insert( conversion_map[tag] );
            }
        }
    }
    if (ret.empty()) {
        ret.insert(fallback);
    }

    return ret;
}
开发者ID:Argoroth,项目名称:Cataclysm-DDA,代码行数:18,代码来源:monstergenerator.cpp

示例5: emitLibraryFunctions

void HlslLinker::emitLibraryFunctions(const std::set<TOperator>& libFunctions, EShLanguage lang, bool usePrecision)
{
	// library Functions & required extensions
	std::string shaderLibFunctions;
	if (!libFunctions.empty())
	{
		for (std::set<TOperator>::const_iterator it = libFunctions.begin(); it != libFunctions.end(); it++)
		{
			const std::string &func = getHLSLSupportCode(*it, m_Extensions, lang==EShLangVertex, usePrecision);
			if (!func.empty())
			{
				shaderLibFunctions += func;
				shaderLibFunctions += '\n';
			}
		}
	}
	shader << shaderLibFunctions;
}
开发者ID:KonajuGames,项目名称:hlsl2glslfork,代码行数:18,代码来源:hlslLinker.cpp

示例6: checkUnknownPattern

void CheckInternal::checkUnknownPattern()
{
    static std::set<std::string> knownPatterns;
    if (knownPatterns.empty()) {
        knownPatterns.insert("%any%");
        knownPatterns.insert("%var%");
        knownPatterns.insert("%type%");
        knownPatterns.insert("%num%");
        knownPatterns.insert("%bool%");
        knownPatterns.insert("%str%");
        knownPatterns.insert("%varid%");
        knownPatterns.insert("%or%");
        knownPatterns.insert("%oror%");
        knownPatterns.insert("%op%");
    }

    for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
        if (!Token::simpleMatch(tok, "Token :: Match (") && !Token::simpleMatch(tok, "Token :: findmatch ("))
            continue;

        // Get pattern string
        const Token *pattern_tok = tok->tokAt(4)->nextArgument();
        if (!pattern_tok || pattern_tok->type() != Token::eString)
            continue;

        const std::string pattern = pattern_tok->strValue();
        bool inBrackets = false;

        for (std::string::size_type i = 0; i < pattern.length()-1; i++) {
            if (pattern[i] == '[' && (i == 0 || pattern[i-1] == ' '))
                inBrackets = true;
            else if (pattern[i] == ']')
                inBrackets = false;
            else if (pattern[i] == '%' && pattern[i+1] != ' ' && pattern[i+1] != '|' && !inBrackets) {
                std::string::size_type end = pattern.find('%', i+1);
                if (end != std::string::npos) {
                    std::string s = pattern.substr(i, end-i+1);
                    if (knownPatterns.find(s) == knownPatterns.end())
                        unknownPatternError(tok, s);
                }
            }
        }
    }
}
开发者ID:NightOfTwelve,项目名称:cppcheck,代码行数:44,代码来源:checkinternal.cpp

示例7: mType

    ItemStack::ItemStack(const MWWorld::Ptr &base, ItemModel *creator, size_t count)
        : mType(Type_Normal)
        , mFlags(0)
        , mCreator(creator)
        , mCount(count)
        , mBase(base)
    {
        if (base.getClass().getEnchantment(base) != "")
            mFlags |= Flag_Enchanted;

        static std::set<std::string> boundItemIDCache;

        // If this is empty then we haven't executed the GMST cache logic yet; or there isn't any sMagicBound* GMST's for some reason
        if (boundItemIDCache.empty())
        {
            // Build a list of known bound item ID's
            const MWWorld::Store<ESM::GameSetting> &gameSettings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

            for (MWWorld::Store<ESM::GameSetting>::iterator currentIteration = gameSettings.begin(); currentIteration != gameSettings.end(); ++currentIteration)
            {
                const ESM::GameSetting &currentSetting = *currentIteration;
                std::string currentGMSTID = currentSetting.mId;
                Misc::StringUtils::toLower(currentGMSTID);

                // Don't bother checking this GMST if it's not a sMagicBound* one.
                const std::string& toFind = "smagicbound";
                if (currentGMSTID.compare(0, toFind.length(), toFind) != 0)
                    continue;

                // All sMagicBound* GMST's should be of type string
                std::string currentGMSTValue = currentSetting.getString();
                Misc::StringUtils::toLower(currentGMSTValue);

                boundItemIDCache.insert(currentGMSTValue);
            }
        }

        // Perform bound item check and assign the Flag_Bound bit if it passes
        std::string tempItemID = base.getCellRef().getRefId();
        Misc::StringUtils::toLower(tempItemID);

        if (boundItemIDCache.count(tempItemID) != 0)
            mFlags |= Flag_Bound;
    }
开发者ID:AAlderman,项目名称:openmw,代码行数:44,代码来源:itemmodel.cpp

示例8: get_parsed_config

config vconfig::get_parsed_config() const
{
	// Keeps track of insert_tag variables.
	static std::set<std::string> vconfig_recursion;

	config res;

	BOOST_FOREACH(const config::attribute &i, cfg_->attribute_range()) {
		res[i.first] = expand(i.first);
	}

	BOOST_FOREACH(const config::any_child &child, cfg_->all_children_range())
	{
		if (child.key == "insert_tag") {
			vconfig insert_cfg(child.cfg);
			const t_string& name = insert_cfg["name"];
			const t_string& vname = insert_cfg["variable"];
			if(!vconfig_recursion.insert(vname).second) {
				throw recursion_error("vconfig::get_parsed_config() infinite recursion detected, aborting");
			}
			try
			{
				config::const_child_itors range = as_nonempty_range(vname);
				BOOST_FOREACH(const config& child, range)
				{
					res.add_child(name, vconfig(child).get_parsed_config());
				}
			}
			catch(const invalid_variablename_exception&)
			{
				res.add_child(name);
			}
			catch(recursion_error &err) {
				vconfig_recursion.erase(vname);
				WRN_NG << err.message << std::endl;
				if(vconfig_recursion.empty()) {
					res.add_child("insert_tag", insert_cfg.get_config());
				} else {
					// throw to the top [insert_tag] which started the recursion
					throw;
				}
			}
			vconfig_recursion.erase(vname);
		} else {
开发者ID:niegenug,项目名称:wesnoth,代码行数:44,代码来源:variable.cpp

示例9: highlightNames

void XLHighlighter::highlightNames(int index, std::set<text> &names)
// ----------------------------------------------------------------------------
//    Set the words to highlight as XL names or symbols
// ----------------------------------------------------------------------------
{
    HighlightingRule &nameRule = highlightingRules[index];
    if (names.empty())
    {
        nameRule.begin = QRegExp("");
        return;
    }
    QStringList w;
    for (std::set<text>::iterator n = names.begin(); n != names.end(); n++)
        w << QRegExp::escape(+*n);
    QString exp = w.join("|");
    if (index != 1)
        exp = QString("\\b(%1)\\b").arg(exp);
    nameRule.begin = QRegExp(exp);
}
开发者ID:caivega,项目名称:tao-3D,代码行数:19,代码来源:xl_highlighter.cpp

示例10: DeleteItems

void DBManager::DeleteItems( std::set<unsigned int> const& ids ) const
{
    if (ids.empty())
    {
        return;
    }

    std::list<std::tstring> idStrings;
    for (std::set<unsigned int>::const_iterator it = ids.begin(); it != ids.end(); ++it)
    {
        idStrings.push_back(STREAM2STR(*it));
    }
    std::tstring idList = boost::join(idStrings, _T(","));

    std::tstringstream sql;
    sql << _T("DELETE FROM tItems WHERE itemidx IN(") << idList << _T(")");

    m_db->Exec(sql.str());
}
开发者ID:MisatoTremor,项目名称:aoia,代码行数:19,代码来源:DBManager.cpp

示例11: getValue

/**
 * @brief Utility method to get value for specified key.
 *
 * Docker supports querying primary columns by prefix. This is preserved when
 * querying throught OSQuery.
 *
 * For example the following should return same result as long as there is only
 * one container with "id" that starts with "12345678":
 *   SELECT * FROM docker_containers WHERE id = '1234567890abcdef'
 *   SELECT * FROM docker_containers WHERE id = '12345678'
 *
 * @param tree Property tree response from docker.
 * @param set Set that might contain prefix values.
 * @param key Key to look for in the property tree.
 */
std::string getValue(const pt::ptree& tree,
                     const std::set<std::string>& set,
                     const std::string& key) {
  std::string value = tree.get<std::string>(key, "");
  if (value.find("sha256:") == 0) {
    value.erase(0, 7);
  }
  if (set.empty()) {
    return value; // Return value from tree, if set is empty
  }

  for (const auto& entry : set) {
    if (value.find(entry) == 0) {
      return entry; // If entry from set is prefix of value from tree, return
    }
  }

  return value;
}
开发者ID:PoppySeedPlehzr,项目名称:osquery,代码行数:34,代码来源:docker.cpp

示例12: chooseLessReplicaNode

int SlaveManager::chooseLessReplicaNode(std::set<Address, AddrComp>& loclist, Address& addr)
{
   if (loclist.empty())
      return -1;

   int min_dist = 1024;
   int64_t min_avail_space = -1;


   // TODO (sergey)

   // Remove a node such that the rest has the max-min distance;
   // When the first rule ties, choose one with least available space.
   for (set<Address, AddrComp>::iterator i = loclist.begin(); i != loclist.end(); ++ i)
   {
      // TODO: optimize this by using ID instead of address.
      set<Address, AddrComp> tmp = loclist;
      tmp.erase(*i);
      int slave_id = m_mAddrList[*i];
      SlaveNode sn = m_mSlaveList[slave_id];
      if( m_mSlaveList.find( slave_id ) == m_mSlaveList.end() )
         log().error << __PRETTY_FUNCTION__ << ": about to add new slave to list " << slave_id << std::endl;
      int64_t availDiskSpace = sn.m_llAvailDiskSpace;

      int dist = m_pTopology->min_distance(*i, tmp);
      if (dist < min_dist)
      {
         addr = *i;
         min_dist = dist;
         min_avail_space = availDiskSpace;
      }
      else if (dist == min_dist)
      {
         if (availDiskSpace < min_avail_space)
         {
            addr = *i;
            min_avail_space = sn.m_llAvailDiskSpace;
         }
      }
   }

   return 0;
}
开发者ID:deniskin82,项目名称:sector-sphere,代码行数:43,代码来源:slavemgmt.cpp

示例13: saveMatrices

 void MatrixArchive::saveMatrices(std::ostream & fout, std::set<std::string> const & validNames) const
 {
   matrix_map_t::const_iterator it = m_values.begin();
   for( ; it != m_values.end(); it++)
   {
     if(validNames.empty() || validNames.count(it->first) > 0)
     {
       if(isSystemLittleEndian())
       {
         writeMatrixBlock(fout, it->first, it->second);
       }
       else
       {
         writeMatrixBlockSwapBytes(fout, it->first, it->second);
       }
       SM_ASSERT_TRUE(MatrixArchiveException, fout.good(), "Error while writing matrix " << it->first << " to file.");
     }
   }
 }
开发者ID:mbuerki,项目名称:Schweizer-Messer,代码行数:19,代码来源:MatrixArchive.cpp

示例14: operator

 void operator()(msgpack::object::with_zone& o, const std::set<T>& v) const {
     o.type = msgpack::type::ARRAY;
     if(v.empty()) {
         o.via.array.ptr = nullptr;
         o.via.array.size = 0;
     } else {
         uint32_t size = checked_get_container_size(v.size());
         msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
         msgpack::object* const pend = p + size;
         o.via.array.ptr = p;
         o.via.array.size = size;
         typename std::set<T>::const_iterator it(v.begin());
         do {
             *p = msgpack::object(*it, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
开发者ID:EricLau2018,项目名称:msgpack-c,代码行数:19,代码来源:set.hpp

示例15: change_sql_database

bool change_sql_database()
{
    if(new_sql_updates.empty()) return true;
    printf("+ changing database sql files\n");

    // rename the database files, copy their contents back
    // and change the required update line
    for(int i = 0; i < NUM_DATABASES; i++)
    {
        if(last_sql_update[i][0] == '\0') continue;

        char old_file[MAX_PATH], tmp_file[MAX_PATH], dummy[MAX_BUF];

        snprintf(old_file, MAX_PATH, "%s%s", path_prefix, db_sql_file[i]);
        snprintf(tmp_file, MAX_PATH, "%s%stmp", path_prefix, db_sql_file[i]);

        rename(old_file, tmp_file);

        FILE *fin = fopen( tmp_file, "r" );
        if(!fin) return false;
        FILE *fout = fopen( old_file, "w" );
        if(!fout) return false;

        while(1)
        {
            if(!fgets(buffer, MAX_BUF, fin)) return false;
            if(sscanf(buffer, "  `required_%s`", dummy) == 1) break;
            fputs(buffer, fout);
        }

        fprintf(fout, "  `required_%s` bit(1) default NULL\n", last_sql_update[i]);
        while(fgets(buffer, MAX_BUF, fin))
            fputs(buffer, fout);

        fclose(fin);
        fclose(fout);
        remove(tmp_file);

        snprintf(cmd, MAX_CMD, "git add %s", old_file);
        system_switch_index(cmd);
    }
    return true;
}
开发者ID:FrenchCORE,项目名称:OLD_FrenchCORE,代码行数:43,代码来源:git_id.cpp


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