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


C++ map::clear方法代码示例

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


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

示例1: CalcTransTable

// ============================================================================
// ==============================================================================
bool CalcTransTable(const std::vector<FORMAT_RES_DATA> &vecResData,
                    std::map<int, int> &mapLookTrans,
                    std::map<int, int> &mapWeaponMotionTrans)
{
    mapLookTrans.clear();
    mapWeaponMotionTrans.clear();

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    std::vector<FORMAT_RES_DATA>::const_iterator it = vecResData.begin();
    std::map<int, std::map<int, int> > mapLookTransCount;
    std::map<int, std::map<int, int> > mapWeaponMotionTransCount;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    for (; it != vecResData.end(); ++it) {

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        const FORMAT_RES_DATA &rData = *it;
        const std::vector<__int64> &rVecIndex = rData.vecIndex;
        __int64 i64IndexRes = ResPathTransIndex(rData.strRes);
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        if (i64IndexRes > 0) {

            //~~~~~~~~~~~~~~~~~~~~~
            int nResLook = 0;
            int nResWeaponMotion = 0;
            //~~~~~~~~~~~~~~~~~~~~~

            GetIndexInfo(i64IndexRes, nResLook, nResWeaponMotion);

            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            std::vector<__int64>::const_iterator itIndex = rVecIndex.begin();
            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            for (; itIndex != rVecIndex.end(); ++itIndex) {

                //~~~~~~~~~~~~~~~~~~~~~~~~
                int nIndexLook = 0;
                int nIndexWeaponMotion = 0;
                __int64 i64Index = *itIndex;
                //~~~~~~~~~~~~~~~~~~~~~~~~

                GetIndexInfo(i64Index, nIndexLook, nIndexWeaponMotion);
                ++mapLookTransCount[nIndexLook][nResLook];
                ++mapWeaponMotionTransCount[nIndexWeaponMotion][nResWeaponMotion];
            }
        }
    }

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    std::map<int, std::map<int, int> >::const_iterator itMap;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    for (itMap = mapLookTransCount.begin(); itMap != mapLookTransCount.end(); ++itMap) {

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        std::map<int, int>::const_iterator it;
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        for (it = itMap->second.begin(); it != itMap->second.end(); ++it) {
            mapLookTrans[itMap->first] = CalMapMaxSecondFirst(itMap->second);
        }
    }

    for (itMap = mapWeaponMotionTransCount.begin(); itMap != mapWeaponMotionTransCount.end(); ++itMap) {

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        std::map<int, int>::const_iterator it;
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        for (it = itMap->second.begin(); it != itMap->second.end(); ++it) {
            mapWeaponMotionTrans[itMap->first] = CalMapMaxSecondFirst(itMap->second);
        }
    }

    return true;
}
开发者ID:piaopolar,项目名称:3DMotionOpt,代码行数:79,代码来源:3dmotionAna.cpp

示例2: calculateChange

// -------------------------------------------------------------------------------------------------------
// Couldn't meet amount exactly, will need to generate change
// returning with a 0 means either too many spends or no change
// Latter should never happen since we should only get here if exact is not possible
// -------------------------------------------------------------------------------------------------------
int calculateChange(
    int nMaxNumberOfSpends,
    bool fMinimizeChange,
    const CAmount nValueTarget,
    const std::map<CoinDenomination, CAmount>& mapOfDenomsHeld,
    std::map<CoinDenomination, CAmount>& mapOfDenomsUsed)
{
    CoinDenomination minDenomOverTarget = ZQ_ERROR;
    // Initialize
    mapOfDenomsUsed.clear();
    for (const auto& denom : zerocoinDenomList)
        mapOfDenomsUsed.insert(std::pair<CoinDenomination, CAmount>(denom, 0));

    for (const auto& denom : zerocoinDenomList) {
        if (nValueTarget < ZerocoinDenominationToAmount(denom) && mapOfDenomsHeld.at(denom)) {
            minDenomOverTarget = denom;
            break;
        }
    }
    // OK so if != ZQ_ERROR we have a solution using 1 coin
    if (minDenomOverTarget != ZQ_ERROR) {
        mapOfDenomsUsed.at(minDenomOverTarget) = 1;

        // Now find out # of coins in change
        CAmount nChangeAmount = ZerocoinDenominationToAmount(minDenomOverTarget) - nValueTarget;
        std::map<CoinDenomination, CAmount> mapChange = getChange(nChangeAmount);
        int nChangeCount = getNumberOfCoinsUsed(mapChange);

        if (fMinimizeChange) {
            CoinDenomination nextToMaxDenom = getNextLowerDenomHeld(minDenomOverTarget, mapOfDenomsHeld);
            int newChangeCount = minimizeChange(nMaxNumberOfSpends, nChangeCount,
                                                nextToMaxDenom, nValueTarget,
                                                mapOfDenomsHeld, mapOfDenomsUsed);

            // Alternative method yields less mints and is less than MaxNumberOfSpends if true
            if (newChangeCount < nChangeCount) return newChangeCount;

            // Reclear
            for (const auto& denom : zerocoinDenomList)
                mapOfDenomsUsed.at(denom) = 0;
            // Then reset as before previous clearing
            mapOfDenomsUsed.at(minDenomOverTarget) = 1;
        }

        return nChangeCount;

    } else {
        // Try to meet a different way
        for (const auto& denom : zerocoinDenomList)
            mapOfDenomsUsed.at(denom) = 0;
        CAmount nRemainingValue = nValueTarget;
        int nCoinCount = 0;
        CAmount AmountUsed = 0;
        for (const auto& denom : reverse_iterate(zerocoinDenomList)) {
            CAmount nValue = ZerocoinDenominationToAmount(denom);
            do {
                if (mapOfDenomsHeld.at(denom) && nRemainingValue > 0) {
                    mapOfDenomsUsed.at(denom)++;
                    AmountUsed += nValue;
                    nRemainingValue -= nValue;
                    nCoinCount++;
                }
            } while ((nRemainingValue > 0) && (mapOfDenomsUsed.at(denom) < mapOfDenomsHeld.at(denom)));
            if (nRemainingValue < 0) break;
        }

        CAmount nChangeAmount = AmountUsed - nValueTarget;
        std::map<CoinDenomination, CAmount> mapChange = getChange(nChangeAmount);
        int nMaxChangeCount = getNumberOfCoinsUsed(mapChange);

        // Instead get max Denom held
        CoinDenomination maxDenomHeld = getMaxDenomHeld(mapOfDenomsHeld);

        // Assign for size (only)
        std::map<CoinDenomination, CAmount> mapOfMinDenomsUsed = mapOfDenomsUsed;

        int nChangeCount = minimizeChange(nMaxNumberOfSpends, nMaxChangeCount,
                                          maxDenomHeld, nValueTarget,
                                          mapOfDenomsHeld, mapOfMinDenomsUsed);

        int nNumSpends = getNumberOfCoinsUsed(mapOfMinDenomsUsed);

        if (!fMinimizeChange && (nCoinCount < nNumSpends)) {
            return nMaxChangeCount;
        }

        mapOfDenomsUsed = mapOfMinDenomsUsed;
        return nChangeCount;
    }
}
开发者ID:ionomy,项目名称:ion,代码行数:95,代码来源:denomination_functions.cpp

示例3: clear

void CNodeDefManager::clear()
{
	m_content_features.clear();
	m_name_id_mapping.clear();
	m_name_id_mapping_with_aliases.clear();
	m_group_to_items.clear();
	m_next_id = 0;

	resetNodeResolveState();

	u32 initial_length = 0;
	initial_length = MYMAX(initial_length, CONTENT_UNKNOWN + 1);
	initial_length = MYMAX(initial_length, CONTENT_AIR + 1);
	initial_length = MYMAX(initial_length, CONTENT_IGNORE + 1);
	m_content_features.resize(initial_length);

	// Set CONTENT_UNKNOWN
	{
		ContentFeatures f;
		f.name = "unknown";
		// Insert directly into containers
		content_t c = CONTENT_UNKNOWN;
		m_content_features[c] = f;
		addNameIdMapping(c, f.name);
	}

	// Set CONTENT_AIR
	{
		ContentFeatures f;
		f.name                = "air";
		f.drawtype            = NDT_AIRLIKE;
		f.param_type          = CPT_LIGHT;
		f.light_propagates    = true;
		f.sunlight_propagates = true;
		f.walkable            = false;
		f.pointable           = false;
		f.diggable            = false;
		f.buildable_to        = true;
		f.floodable           = true;
		f.is_ground_content   = true;
		// Insert directly into containers
		content_t c = CONTENT_AIR;
		m_content_features[c] = f;
		addNameIdMapping(c, f.name);
	}

	// Set CONTENT_IGNORE
	{
		ContentFeatures f;
		f.name                = "ignore";
		f.drawtype            = NDT_AIRLIKE;
		f.param_type          = CPT_NONE;
		f.light_propagates    = false;
		f.sunlight_propagates = false;
		f.walkable            = false;
		f.pointable           = false;
		f.diggable            = false;
		f.buildable_to        = true; // A way to remove accidental CONTENT_IGNOREs
		f.is_ground_content   = true;
		// Insert directly into containers
		content_t c = CONTENT_IGNORE;
		m_content_features[c] = f;
		addNameIdMapping(c, f.name);
	}
}
开发者ID:4aiman,项目名称:minetest,代码行数:65,代码来源:nodedef.cpp

示例4: mexFunction

// *********************************************************************
// *                        Matlab entry point                         *
// *********************************************************************
void mexFunction (int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs)
{
    int command;

    // Cleanup function - register only once
    static bool cleanupRegistered = false;
    if (!cleanupRegistered) {
        // Yay for C++11 lambdas
        mexAtExit([] () {
            std::cout << "Cleaning up the onyx Linear LaRank MEX wrapper!" << std::endl;
            // Clear all the objects to free their memory
            objects.clear();
        });
    }

    // We need at least one argument - command
    if (nrhs < 1) {
        mexErrMsgTxt("Wrapper requires at least one argument!");
    }

    if (mxGetNumberOfElements(prhs[0]) != 1 || !mxIsNumeric(prhs[0])) {
        mexErrMsgTxt("First argument needs to be a numeric command!");
    }

    command = static_cast<int>(mxGetScalar(prhs[0]));

    // Skip the command
    nrhs--;
    prhs++;

    switch (command) {
        case CommandCreate: {
            return classifier_create(nlhs, plhs, nrhs, prhs);
        }
        case CommandDelete: {
            return classifier_delete(nlhs, plhs, nrhs, prhs);
        }
        case CommandPredict: {
            return classifier_predict(nlhs, plhs, nrhs, prhs);
        }
        case CommandUpdate: {
            return classifier_update(nlhs, plhs, nrhs, prhs);
        }
        case CommandSerialize: {
            return classifier_serialize(nlhs, plhs, nrhs, prhs);
        }
        case CommandDeserialize: {
            return classifier_deserialize(nlhs, plhs, nrhs, prhs);
        }
        case CommandGetC: {
            return classifier_get_c(nlhs, plhs, nrhs, prhs);
        }
        case CommandSetC: {
            return classifier_set_c(nlhs, plhs, nrhs, prhs);
        }
        case CommandGetTau: {
            return classifier_get_tau(nlhs, plhs, nrhs, prhs);
        }
        case CommandSetTau: {
            return classifier_set_tau(nlhs, plhs, nrhs, prhs);
        }
        case CommandGetNumFeatures: {
            return classifier_get_num_features(nlhs, plhs, nrhs, prhs);
        }
        case CommandGetNumClasses: {
            return classifier_get_num_classes(nlhs, plhs, nrhs, prhs);
        }
        case CommandGetClassLabels: {
            return classifier_get_class_labels(nlhs, plhs, nrhs, prhs);
        }
        case CommandGetNumSeenSamples: {
            return classifier_get_num_seen_samples(nlhs, plhs, nrhs, prhs);
        }
        case CommandGetDecisionFunctionWeights: {
            return classifier_get_decision_function_weights(nlhs, plhs, nrhs, prhs);
        }
        default: {
            mexErrMsgTxt("Unrecognized command value!");
        }
    }
}
开发者ID:rokm,项目名称:onyx,代码行数:84,代码来源:linear_larank_mex.cpp

示例5: DoPulse

///////////////////////////////////////////////////////////////
//
// CPerfStatFunctionTimingImpl::DoPulse
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatFunctionTimingImpl::DoPulse ( void )
{
    // Maybe turn off stats gathering if nobody is watching
    if ( m_bIsActive && m_TimeSinceLastViewed.Get () > 15000 )
        SetActive ( false );

    // Do nothing if not active
    if ( !m_bIsActive )
    {
        m_TimingMap.clear ();
        return;
    }

    // Check if time to cycle the stats
    if ( m_TimeSinceUpdate.Get () >= 10000 )
    {
        m_TimeSinceUpdate.Reset ();

        // For each timed function
        for ( std::map < SString, SFunctionTimingInfo >::iterator iter = m_TimingMap.begin () ; iter != m_TimingMap.end () ; )
        {
            SFunctionTimingInfo& item = iter->second;
            // Update history
            item.iPrevIndex = ( item.iPrevIndex + 1 ) % NUMELMS( item.history );
            item.history[ item.iPrevIndex ] = item.now5s;

            // Reset accumulator
            item.now5s.uiNumCalls = 0;

            item.now5s.fTotalMs = 0;
            item.now5s.fPeakMs = 0;
            item.now5s.fResBiggestMs = 0;
            item.now5s.strResBiggestMsName.clear();

            item.now5s.uiTotalBytes = 0;
            item.now5s.uiPeakBytes = 0;
            item.now5s.uiResBiggestBytes = 0;
            item.now5s.strResBiggestBytesName.clear();

            // Recalculate last 60 second stats
            item.prev60s.uiNumCalls = 0;

            item.prev60s.fTotalMs = 0;
            item.prev60s.fPeakMs = 0;
            item.prev60s.fResBiggestMs = 0;
            item.prev60s.strResBiggestMsName.clear();

            item.prev60s.uiTotalBytes = 0;
            item.prev60s.uiPeakBytes = 0;
            item.prev60s.uiResBiggestBytes = 0;
            item.prev60s.strResBiggestBytesName.clear();

            for ( uint i = 0 ; i < NUMELMS( item.history ) ; i++ )
            {
                const STiming& slot = item.history[i];
                item.prev60s.uiNumCalls += slot.uiNumCalls;

                item.prev60s.fTotalMs += slot.fTotalMs;
                item.prev60s.fPeakMs = Max ( item.prev60s.fPeakMs, slot.fPeakMs );
                if ( item.prev60s.fResBiggestMs < slot.fTotalMs )
                {
                    item.prev60s.fResBiggestMs = slot.fTotalMs;
                    item.prev60s.strResBiggestMsName = slot.strResBiggestMsName;
                }

                item.prev60s.uiTotalBytes += slot.uiTotalBytes;
                item.prev60s.uiPeakBytes = Max ( item.prev60s.uiPeakBytes, slot.uiPeakBytes );
                if ( item.prev60s.uiResBiggestBytes < slot.uiTotalBytes )
                {
                    item.prev60s.uiResBiggestBytes = slot.uiTotalBytes;
                    item.prev60s.strResBiggestBytesName = slot.strResBiggestBytesName;
                }
            }

            // Remove from map if no calls in the last 60s
            if ( item.prev60s.uiNumCalls == 0 )
                m_TimingMap.erase ( iter++ );
            else
                ++iter;
        }
    }

    //
    // Update PeakUs threshold
    //
    m_PeakUsRequiredHistory.RemoveOlderThan ( 10000 );
    ms_PeakUsThresh = m_PeakUsRequiredHistory.GetLowestValue ( DEFAULT_THRESH_MS * 1000 );
}
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:95,代码来源:CPerfStat.FunctionTiming.cpp

示例6: reset

void mutation_category_trait::reset()
{
    mutation_category_traits.clear();
}
开发者ID:ymber,项目名称:Cataclysm-DDA,代码行数:4,代码来源:mutation_data.cpp

示例7: clear_visibility_cache

	/**
	 * Clears the cache.
	 *
	 * Since we don't change the state of the object we're marked const (also
	 * required since the objects in the cache need to be marked const).
	 */
	void clear_visibility_cache() const { invisibility_cache_.clear(); }
开发者ID:dodikk,项目名称:iWesnoth,代码行数:7,代码来源:unit.hpp

示例8: parse_kv

  // return index of error, or -1 on success
  int parse_kv(std::string str)
  {
    keyvals.clear();
    _error.str("");

    std::vector<char> current_key;
    std::vector<char> current_val;

    int i = 0;
    while(str[i])
      {
        current_key.clear();
        current_val.clear();
        while(isspace(str[i])) i++;
        while(str[i]) {
          if(str[i] == '"') {
            _error << "key names are not allowed to contain quotes or be contained in quotes.";
            return i;
          } else if(isspace(str[i])) {
            _error << "unexpected whitespace.";
            return i;
          } else if(str[i] == '=') {
            i++;
            break;
          } else current_key.push_back(str[i++]);
        }
        if(!current_key.size()) {
          _error << "empty key name.";
          return i;
        }
        bool quoted = false;
        if(str[i] == '"') {
          quoted = true;
          i++;
        }
        while(str[i]) {
          if(str[i] == '"') {
            if(quoted) {
              quoted = false;
              i++;
              break;
            } else {
              _error << "misplaced quotes.";
              return i;
            }
          } else if(str[i] == '=') {
            _error << "unexpected '=' char in value token.";
            return i;
          } else if(!quoted && isspace(str[i])) break;
          else current_val.push_back(str[i++]);
        }
        if(quoted) {
          _error << "unterminated quotes.";
          return i;
        }
        if(str[i] && !isspace(str[i])) {
          _error << "expected whitespace after value token.";
          return i;
        }
        if(!current_val.size()) {
          _error << "empty value string.";
          return i;
        }
        std::string key = std::string(current_key.data(), current_key.size());
        std::string val = std::string(current_val.data(), current_val.size());

        if(keyvals.find(key) != keyvals.end())
          {
            _error << "duplicate key encountered: '" << key << "'";
            return i;
          }
        keyvals[key] = val;
      }

    return -1;
  }
开发者ID:godbyk,项目名称:vrpn,代码行数:77,代码来源:vrpn_Tracker_PhaseSpace.C

示例9: do_task

    /*!
        Execute a boost::threadpool::pool task.
        \param type Type of task to execute.
        \param username Person who is the base of a task.
        \param change What value to change as part of their statistic.
    */
    void do_task(const Task_Type type, const int id, const int change)
    {
        boost::shared_lock<boost::shared_mutex> guard(mutex);
        switch (type) {
        case RESET_TASK:
            statistics.clear();
            break;

        case ADD_TASK:
            // Add a player to the player list.
            try {
                const std::map<int, VTankObject::Statistics>::iterator i = statistics.find(id);
                if (i != statistics.end()) {
                    // Exists already. Do nothing.
                    return;
                }

                const tank_ptr tank = Players::tanks.get(id);

                VTankObject::Statistics stats = VTankObject::Statistics();
                stats.tankName = tank->get_name();
                stats.kills = 0;
                stats.deaths = 0;
                stats.assists = 0;
                stats.objectivesCaptured = 0;
                stats.objectivesCompleted = 0;
                stats.calculatedPoints = 0;

                statistics[id] = stats;
            }
            catch (const TankNotExistException &) {
            }
            
            break;

        case KILL_TASK:
            // Add a kill to the player's record.
            statistics[id].kills += change;
            break;

        case ASSIST_TASK:
            // Add an assist to the player's record.
            statistics[id].assists += change;
            break;

        case DEATH_TASK:
            // Add a death to the player's record.
            statistics[id].deaths += change;
            break;

        case OBJECTIVE_TASK:
            // Add an objective completion to the player's record.
            statistics[id].objectivesCompleted += change;
            break;

        case CAPTURE_TASK:
            // Add an objective capture to the player's record.
            statistics[id].objectivesCaptured += change;
            break;
        }
    }
开发者ID:summer-of-software,项目名称:vtank,代码行数:67,代码来源:pointmanager.cpp

示例10: Clear

 void Clear() { histo.clear(); }
开发者ID:yohm,项目名称:dynamical_graph_model,代码行数:1,代码来源:dynamical_graph_model.cpp

示例11: clearIndex

void FileFilterIndex::clearIndex(std::map<std::string, int> indexMap)
{
	indexMap.clear();
}
开发者ID:RetroPie,项目名称:EmulationStation,代码行数:4,代码来源:FileFilterIndex.cpp

示例12: main

int main() {
//    freopen("9066in.txt","r",stdin);
//    freopen("9066out.txt","w",stdout);
	int i, j, nq, root;
	memset(pl, 0, sizeof(pl));
	memset(B.r, 0, sizeof(B.r));
	memset(q, 0, sizeof(q));
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	scanf("%d", &nq);
	for (i = 1; i <= nq; i++) {
		char buff[2];
		scanf("%s%d%d", buff, &q[i].x, &q[i].y);
		q[i].tp = buff[0];
		q[i].id = i;
	}
	std::sort(q + 1, q + nq + 1, cmp1);
	pos.clear();
	pcnt = 0;
	newnode(root);
	for (j = 1; j <= nq && q[j].tp == 'U'; j++)
		;
	for (i = 1; i <= n; i++) {
		std::set<int>::iterator it;
		std::set<int>&th = pos[a[i]];
		if (!th.empty()) {
			it = th.end();
			--it;
			refresh(root, 1, n, *it, -a[i]);
			refresh(root, 1, n, i, a[i]);
			th.insert(i);
		} else {
			refresh(root, 1, n, i, a[i]);
			th.insert(i);
		}
		while (j <= nq && q[j].y <= i) {
			q[j].ans = query(root, 1, n, q[j].x, q[j].y);
			j++;
		}
	}
	std::sort(q + 1, q + nq + 1, cmp2);
	pcnt = 0;
	B.init(n);
	for (i = 1; i <= nq; i++) {
		if (q[i].tp == 'Q') {
			LL del = B.sum(q[i].x, 1, q[i].y);
			printf("%lld\n", del + q[i].ans);
		} else {
			PII range;
			getRange(q[i].x, a[q[i].x], range);
			B.add(range.AA + 1, q[i].x, q[i].x, range.BB - 1, -a[q[i].x]);
			getRange(q[i].x, q[i].y, range);
			B.add(range.AA + 1, q[i].x, q[i].x, range.BB - 1, q[i].y);
			pos[a[q[i].x]].erase(q[i].x);
			pos[q[i].y].insert(q[i].x);
			a[q[i].x] = q[i].y;
		}
	}
	return 0;
}
开发者ID:weskerhluffy,项目名称:caca_x,代码行数:61,代码来源:shame.cpp

示例13: readTextureList

void TexturePack::readTextureList(const char* texturelistfile,
								  std::vector<Rect>& textures_,
								  std::map<std::string, int>& filenameMap_,
								  int* pwidth, int* pheight)
{
	G_FILE* fis = g_fopen(texturelistfile, "rt");

	if (fis == NULL)
	{
		throw GiderosException(GStatus(6000, texturelistfile));		// Error #6000: %s: No such file or directory.
		return;
	}

	textures_.clear();
	filenameMap_.clear();

	int width = 0;
	int height = 0;

	char line[1024];

	while (true)
	{
		line[0] = line[1023] = 0;
		if (g_fgets(line, 1024, fis) == NULL)
			break;

		char* c;
		if ((c = strrchr(line, 0xa)))
			*c = '\0';
		if ((c = strrchr(line, 0xd)))
			*c = '\0';

		if (line[0] == '\0')
			break;

		std::vector<std::string> result;
		pystring::split(line, result, ",");

		for (std::size_t i = 0; i < result.size(); ++i)
		{
			if (result[i].empty() == false)
				result[i] = pystring::strip(result[i]);
		}

		if (result.size() >= 9)
		{
			Rect rect;

			rect.x = atoi(result[1].c_str());
			rect.y = atoi(result[2].c_str());
			rect.width = atoi(result[3].c_str());
			rect.height = atoi(result[4].c_str());
			rect.dx1 = atoi(result[5].c_str());
			rect.dy1 = atoi(result[6].c_str());
			rect.dx2 = atoi(result[7].c_str());
			rect.dy2 = atoi(result[8].c_str());

			filenameMap_[result[0]] = textures_.size();
			textures_.push_back(rect);

			width += rect.width + rect.dx1 + rect.dx2;
			height += rect.height + rect.dy1 + rect.dy2;
		}
	}

	g_fclose(fis);

	if (pwidth)
		*pwidth = width;
	if (pheight)
		*pheight = height;

	if (textures_.empty() == true)
	{
		throw GiderosException(GStatus(6008, texturelistfile));		// Error #6008: %s: File does not contain texture region information.
		return;
	}
}
开发者ID:Nlcke,项目名称:gideros,代码行数:79,代码来源:texturepack.cpp

示例14: AdvanceReduce

// ============================================================================
// ==============================================================================
bool AdvanceReduce(const std::map<__int64, std::string> &rMapOrgInfo,
                   const std::vector<FORMAT_RES_DATA> &vecResData,
                   std::map<__int64, std::string> &mapNewIndex,
                   std::map<int, int> &mapLookTrans,
                   std::map<int, int> &mapWeaponMotionTrans)
{
    mapNewIndex.clear();

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    std::vector<FORMAT_RES_DATA>::const_iterator it = vecResData.begin();
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    for (; it != vecResData.end(); ++it) {

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        const FORMAT_RES_DATA &rData = *it;
        const std::vector<__int64> &rVecIndex = rData.vecIndex;
        __int64 i64IndexRes = ResPathTransIndex(rData.strRes);
        bool bIndexResOk = true;
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        if (i64IndexRes <= 0) {
            bIndexResOk = false;
        }

        if (bIndexResOk) {

            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            std::map<__int64, std::string>::const_iterator it = rMapOrgInfo.find(i64IndexRes);
            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            if (it == rMapOrgInfo.end() || it->second != rData.strRes) {
                bIndexResOk = false;
            }
        }

        if (!bIndexResOk) {

            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            std::vector<__int64>::const_iterator itIndex = rVecIndex.begin();
            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            for (; itIndex != rVecIndex.end(); ++itIndex) {

                //~~~~~~~~~~~~~~~~~~~~~~~~
                __int64 i64Index = *itIndex;
                //~~~~~~~~~~~~~~~~~~~~~~~~

                if (REDUCE_VERSION > 1) {

                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    __int64 i64IndexRuleTrans = MountRuleTrans(i64Index);
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                    if (i64IndexRuleTrans != i64Index) {

                        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        const std::map<__int64, std::string>::const_iterator itRule = rMapOrgInfo.find(i64IndexRuleTrans);
                        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                        if (itRule != rMapOrgInfo.end() && itRule->second == rData.strRes) {
                            continue;
                        }
                    }
                }

                mapNewIndex[i64Index] = rData.strRes;
            }
        } else {
            mapNewIndex[i64IndexRes] = rData.strRes;

            //~~~~~~~~~~~~~~~~~~~~~
            int nResLook = 0;
            int nResWeaponMotion = 0;
            //~~~~~~~~~~~~~~~~~~~~~

            GetIndexInfo(i64IndexRes, nResLook, nResWeaponMotion);

            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            std::vector<__int64>::const_iterator itIndex = rVecIndex.begin();
            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            for (; itIndex != rVecIndex.end(); ++itIndex) {

                //~~~~~~~~~~~~~~~~~~~~~~~~
                int nIndexLook = 0;
                int nIndexWeaponMotion = 0;
                __int64 i64Index = *itIndex;
                //~~~~~~~~~~~~~~~~~~~~~~~~

                if (REDUCE_VERSION > 1) {

                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    __int64 i64IndexRuleTrans = MountRuleTrans(i64Index);
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                    if (i64IndexRuleTrans != i64Index) {

//.........这里部分代码省略.........
开发者ID:piaopolar,项目名称:3DMotionOpt,代码行数:101,代码来源:3dmotionAna.cpp

示例15: DispatchEvent


//.........这里部分代码省略.........
					List_ResetContent( hwndListFunk );
					for (i = 0; i < nsFuncCode::nFuncList_Special_Num; i++) {
						List_AddString( hwndListFunk, LS(nsFuncCode::pnFuncList_Special[i]) );
					}
				}
				else {
					/* 機能一覧に文字列をセット(リストボックス)*/
					m_cLookup.SetListItem( hwndListFunk, nIdxFIdx );
				}

				return TRUE;
			}
		}
		else{
			switch( wNotifyCode ){
			/* ボタン/チェックボックスがクリックされた */
			case BN_CLICKED:
				switch( wID ){
				case IDC_BUTTON_IMPORT:	/* インポート */
					/* カスタムメニュー設定をインポートする */
					Import( hwndDlg );
					return TRUE;
				case IDC_BUTTON_EXPORT:	/* エクスポート */
					/* カスタムメニュー設定をエクスポートする */
					Export( hwndDlg );
					return TRUE;

				case IDC_BUTTON_CLEAR:
					if (IDCANCEL == ::MYMESSAGEBOX( hwndDlg, MB_OKCANCEL | MB_ICONQUESTION, GSTR_APPNAME,
						LS(STR_PROPCOMMAINMENU_CLEAR)) ) {
						return TRUE;
					}
					// 内部データ初期化
					msMenu.clear();
					nMenuCnt = 0;
					// TreeView初期化
					TreeView_DeleteAllItems( hwndTreeRes );
					return TRUE;

				case IDC_BUTTON_INITIALIZE:
					if (IDCANCEL == ::MYMESSAGEBOX( hwndDlg, MB_OKCANCEL | MB_ICONQUESTION, GSTR_APPNAME,
						LS(STR_PROPCOMMAINMENU_INIT))) {
						return TRUE;
					}
					// 初期状態に戻す
					{
						CDataProfile	cProfile;
						std::vector<std::wstring> data;
						cProfile.SetReadingMode();
						cProfile.ReadProfileRes( MAKEINTRESOURCE(IDR_MENU1), MAKEINTRESOURCE(ID_RC_TYPE_INI), &data );

						CShareData_IO::IO_MainMenu( cProfile, &data, m_Common.m_sMainMenu, false );
						
						SetData( hwndDlg ); 
					}
					return TRUE;

				case IDC_BUTTON_DELETE:
					htiItem = TreeView_GetSelection( hwndTreeRes );
					if (htiItem != NULL) {
						if (TreeView_GetChild( hwndTreeRes, htiItem ) != NULL
						  && IDCANCEL == ::MYMESSAGEBOX( hwndDlg, MB_OKCANCEL | MB_ICONQUESTION, GSTR_APPNAME,
							LS(STR_PROPCOMMAINMENU_DEL))) {
							return TRUE;
						}
						htiTemp = TreeView_GetNextSibling( hwndTreeRes, htiItem );
开发者ID:daisukekoba,项目名称:sakura-editor-trunk2,代码行数:67,代码来源:CPropComMainMenu.cpp


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