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


C++ GetRank函数代码示例

本文整理汇总了C++中GetRank函数的典型用法代码示例。如果您正苦于以下问题:C++ GetRank函数的具体用法?C++ GetRank怎么用?C++ GetRank使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: GetPreset

u32 CUIMpTradeWnd::GetPresetCost(ETradePreset idx)
{
	const preset_items&		v			=  GetPreset(idx);
	preset_items::const_iterator it		= v.begin();
	preset_items::const_iterator it_e	= v.end();

	u32 result							= 0;
	for(;it!=it_e;++it)
	{
		const _preset_item& _one		= *it;

		u32 _item_cost					= m_item_mngr->GetItemCost(_one.sect_name, GetRank() );

		if(_one.addon_names[0].c_str())
			_item_cost					+= m_item_mngr->GetItemCost(_one.addon_names[0], GetRank() );
		
		if(_one.addon_names[1].c_str())
			_item_cost					+= m_item_mngr->GetItemCost(_one.addon_names[1], GetRank() );

		if(_one.addon_names[2].c_str())
			_item_cost					+= m_item_mngr->GetItemCost(_one.addon_names[2], GetRank() );

		_item_cost						*= _one.count;

		result							+= _item_cost;
	}
	return result;
}
开发者ID:2asoft,项目名称:xray,代码行数:28,代码来源:UIMpTradeWnd_misc.cpp

示例2: assert

// initial condition: out must have all its header fields filled in (gen, num_blocks_gen, block_size)
bool NC::ReEncodeBlock(std::vector<CodedBlockPtr> &buffer, CodedBlock *out) {

	assert( out != NULL);

	int i, j;
	int gen = out->gen;
	int num_blocks_gen = out->num_blocks_gen;
	int block_size = out->block_size;

	/*
	 if( !buffer[gen].size() )
	 return;
	 */

	if (!GetRank(&buffer))
		return false;

	memset(out->coeffs, 0, num_blocks_gen);
	memset(out->sums, 0, (is_sim ? 1 : block_size));

	unsigned char *randCoeffs = new unsigned char[num_blocks_gen];

	// generate randomized coefficients 
	// coefficients are drawn uniform randomly from {1, ..., 2^fsize}

	int field_limit = (int) 1 << (int) field_size;

#ifdef WIN32
	srand((unsigned int)GetTickCount());
#else
	srand(time(NULL));
#endif

	for (i = 0; i < GetRank(&buffer); ++i)
		while (!(randCoeffs[i] = (unsigned char) (rand() % field_limit)))
			;

	// generate a coded piece from a set of coded pieces. { c_0, ... c_{GetRank()-1} }
	// c_i = {COEFFs, SUMs(i.e., coded symbols)} in the buffer (coded piece buffer in NC)
	// re-encoded piece = a_0*c_0 + a_1*c_1 + ... + a_{GetRank()-1}*c_{GetRank()-1}
	// where a_0, a_1, ..., a_{GetRank()} are random coefficients in randCoeffs[i]

	for (i = 0; i < GetRank(&buffer); ++i) {

		for (j = 0; j < num_blocks_gen; ++j) {

			out->coeffs[j] = gf->Add(gf->Mul(buffer[i]->coeffs[j], randCoeffs[i], field_size), out->coeffs[j],
					field_size);
		}
		for (j = 0; j < (is_sim ? 1 : block_size); ++j) {

			out->sums[j] = gf->Add(gf->Mul(buffer[i]->sums[j], randCoeffs[i], field_size), out->sums[j], field_size);
		}
	}

	delete[] randCoeffs;
	return true;
}
开发者ID:uclanrl,项目名称:codetorrent,代码行数:59,代码来源:nc.cpp

示例3: CollectReferences

void
Assignment::Prepare(void)
{
CollectReferences( );      //collect the referenced entities   


vector<Control*>::iterator it=GetSurroundingControls( )->begin();
Condition*   domain=new Condition(new Inequation(true));
while(it != GetSurroundingControls( )->end())
   {
   Control* st;
    
   if((*it)->IsLoop())
      AddCounter( (*it)->GetLoopCounter());

   Condition*   __st_domain=(*it)->GetDomainConstraints(GetRank());

   domain= new Condition(domain,FADA_AND,  __st_domain);
   ++it;
   }

Condition*   __no_not= domain->EliminateNotOperations();
Condition*   __dnform= __no_not->DNForm();
vector<Condition*>* new_domain=new vector<Condition*>();
*new_domain=__dnform->GetTerms();

SetDomain(new_domain);
}
开发者ID:mbelaoucha,项目名称:fadalib,代码行数:28,代码来源:assignment.cpp

示例4: BackSubstitution

bool NC::BackSubstitution(std::vector<CodedBlockPtr> buffer, unsigned char **m_upper, unsigned char **m_data) {

	unsigned char tmp;

	int i, j, k;

	int num_blocks_gen = buffer[0]->num_blocks_gen;
	int block_size = buffer[0]->block_size;

	if (GetRank(&buffer) != num_blocks_gen) //check the GetRank() func parameter
		return false;

	for (i = num_blocks_gen - 1; i >= 0; i--) {

		for (j = 0; j < (is_sim ? 1 : block_size); j++) {

			tmp = (unsigned char) 0x0;

			for (k = i + 1; k < num_blocks_gen; k++) {
				tmp = gf->Add(tmp, gf->Mul(m_upper[i][k], m_data[k][j], field_size), field_size);
			}

			m_data[i][j] = gf->Div(gf->Sub(m_upper[i][num_blocks_gen + j], tmp, field_size), m_upper[i][i], field_size);
		}
	}

	return true;
}
开发者ID:uclanrl,项目名称:codetorrent,代码行数:28,代码来源:nc.cpp

示例5: SetReputation

bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
    // used by eluna
    sHookMgr->OnReputationChange(m_player, factionEntry->ID, standing, incremental);

    bool res = false;
    // if spillover definition exists in DB
    if (const RepSpilloverTemplate *repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
    {
        for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
        {
            if (repTemplate->faction[i])
            {
                if (GetRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i]))
                {
                    // bonuses are already given, so just modify standing by rate
                    int32 spilloverRep = standing * repTemplate->faction_rate[i];
                    SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental);
                }
            }
        }
    }

    // spillover done, update faction itself
    FactionStateList::iterator faction = m_factions.find(factionEntry->reputationListID);
    if (faction != m_factions.end())
    {
        res = SetOneFactionReputation(factionEntry, standing, incremental);
        // only this faction gets reported to client, even if it has no own visible standing
        SendState(&faction->second);
    }

    return res;
}
开发者ID:Blumfield,项目名称:ptc2,代码行数:34,代码来源:ReputationMgr.cpp

示例6: GetRank

short unsigned FiveEval::GetRank(int const card_one, const int card_two,
                                 const int card_three, const int card_four,
                                 const int card_five, const int card_six,
                                 const int card_seven) const {
  int seven_cards[7] = {card_one, card_two, card_three, card_four, card_five,
    card_six, card_seven};
  int temp[5];
  
  short unsigned best_rank_so_far = 0, current_rank = 0;
  int m = 0;
  
  for (int i = 1; i < 7; ++i) {
    for (int j = 0; j < i; ++j) {
      m = 0;
      for (int k = 0; k < 7; ++k) {
        if (k != i && k !=j) {
          temp[m++] = seven_cards[k];
        }
      }
      current_rank = GetRank(temp[0], temp[1], temp[2], temp[3], temp[4]);
      if (best_rank_so_far < current_rank) {
        best_rank_so_far = current_rank;
      }
    }
  }
  return best_rank_so_far;
}
开发者ID:4rapid,项目名称:SpecialKEval,代码行数:27,代码来源:FiveEval.cpp

示例7: DetachAddon

void CUIMpTradeWnd::SellItemAddons(SBuyItemInfo* sell_itm, item_addon_type addon_type)
{
	CInventoryItem* item_	= (CInventoryItem*)sell_itm->m_cell_item->m_pData;
	CWeapon* w				= smart_cast<CWeapon*>(item_);
	if(!w)					return; //ammo,medkit etc.

	if(IsAddonAttached(sell_itm, addon_type))
	{
		SBuyItemInfo* detached_addon	= DetachAddon(sell_itm, addon_type);
		u32 _item_cost					= m_item_mngr->GetItemCost(detached_addon->m_name_sect, GetRank() );
		SetMoneyAmount					(GetMoneyAmount() + _item_cost);
		DestroyItem						(detached_addon);

		if ( addon_type == at_glauncher )
		{
			CWeaponMagazinedWGrenade* wpn2 = smart_cast<CWeaponMagazinedWGrenade*>(item_);
			VERIFY(wpn2);

			for ( u32 ammo_idx							=	0;
					  ammo_idx							<	wpn2->m_ammoTypes2.size();
					++ammo_idx )
			{
				const shared_str&	ammo_name			=	wpn2->m_ammoTypes2[ammo_idx];
				SBuyItemInfo*		ammo				=	NULL;

				while ( (ammo = FindItem(ammo_name, SBuyItemInfo::e_bought)) != NULL )
				{
					SBuyItemInfo*   tempo				=	NULL;
					TryToSellItem(ammo, true, tempo);
				}
			}
		}
	}
}
开发者ID:2asoft,项目名称:xray,代码行数:34,代码来源:UIMpTradeWnd_wpn.cpp

示例8: Initialize

void ReputationMgr::LoadFromDB(PreparedQueryResult result)
{
    // Set initial reputations (so everything is nifty before DB data load)
    Initialize();

    //QueryResult* result = CharacterDatabase.PQuery("SELECT faction, standing, flags FROM character_reputation WHERE guid = '%u'", GetGUIDLow());

    if (result)
    {
        do
        {
            Field* fields = result->Fetch();

            FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt16());
            if (factionEntry && (factionEntry->reputationListID >= 0))
            {
                FactionState* faction = &_factions[factionEntry->reputationListID];

                // update standing to current
                faction->Standing = fields[1].GetInt32();

                // update counters
                int32 BaseRep = GetBaseReputation(factionEntry);
                ReputationRank old_rank = ReputationToRank(BaseRep);
                ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing);
                UpdateRankCounters(old_rank, new_rank);

                uint32 dbFactionFlags = fields[2].GetUInt16();

                if (dbFactionFlags & FACTION_FLAG_VISIBLE)
                    SetVisible(faction);                    // have internal checks for forced invisibility

                if (dbFactionFlags & FACTION_FLAG_INACTIVE)
                    SetInactive(faction, true);              // have internal checks for visibility requirement

                if (dbFactionFlags & FACTION_FLAG_AT_WAR)  // DB at war
                    SetAtWar(faction, true);                 // have internal checks for FACTION_FLAG_PEACE_FORCED
                else                                        // DB not at war
                {
                    // allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
                    if (faction->Flags & FACTION_FLAG_VISIBLE)
                        SetAtWar(faction, false);            // have internal checks for FACTION_FLAG_PEACE_FORCED
                }

                // set atWar for hostile
                if (GetRank(factionEntry) <= REP_HOSTILE)
                    SetAtWar(faction, true);

                // reset changed flag if values similar to saved in DB
                if (faction->Flags == dbFactionFlags)
                {
                    faction->needSend = false;
                    faction->needSave = false;
                }
            }
        }
        while (result->NextRow());
    }
}
开发者ID:Hlkz2,项目名称:ACoreOld,代码行数:59,代码来源:ReputationMgr.cpp

示例9: GetDescription

string CIncomingClanList :: GetDescription( )
{
	string Description;
	Description += GetName( ) + "\n";
	Description += GetStatus( ) + "\n";
	Description += GetRank( ) + "\n\n";
	return Description;
}
开发者ID:RiseCakoPlusplus,项目名称:brtGHost,代码行数:8,代码来源:bnetprotocol.cpp

示例10: GetInverse

//==========================================================================
// Class:			Matrix
// Function:		GetInverse
//
// Description:		Returns the inverse of this matrix.  If this matrix is badly
//					scaled or is rectangular, the psuedo-inverse is returned.
//
// Input Arguments:
//		None
//
// Output Arguments:
//		inverse	= Matrix&
//
// Return Value:
//		bool, true for success, false otherwise
//
//==========================================================================
bool Matrix::GetInverse(Matrix &inverse) const
{
	if (!IsSquare() || GetRank() != rows)
		return GetPsuedoInverse(inverse);

	// Don't see a point to having two inverse methods -> always use the same method
	return GetPsuedoInverse(inverse);
}
开发者ID:KerryL,项目名称:RPiSousVide,代码行数:25,代码来源:matrix.cpp

示例11: GetRank

// find the indices of the lattice element that contanis (x,y,z) 
int Lattice::GetIndices(float x, float y, float z, int &iidx, int &jidx, int &kidx) {

  int rank = GetRank(x,y,z); 
  if (rank!=-1) {
    GetIndices(rank, iidx, jidx, kidx); 
    return(rank); 
  }
  else return(-1); 

}
开发者ID:recheliu,项目名称:FlowEntropy,代码行数:11,代码来源:Lattice.C

示例12: IncreaseRank

/// increase rank
void nofActiveSoldier::IncreaseRank()
{   
	//max rank reached? -> dont increase!
	if(MAX_MILITARY_RANK - (GetRank() + GAMECLIENT.GetGGS().getSelection(ADDON_MAX_RANK)) < 1)
		return;
	// Einen Rang höher
    job = Job(unsigned(job) + 1);
	// Inventur entsprechend erhöhen und verringern
    gwg->GetPlayer(player)->IncreaseInventoryJob(job, 1);
    gwg->GetPlayer(player)->DecreaseInventoryJob(Job(unsigned(job) - 1), 1);
}
开发者ID:lweberk,项目名称:s25client,代码行数:12,代码来源:nofActiveSoldier.cpp

示例13: a2

void PhraseTableCreator::EncodeTargetPhraseREnc(std::vector<std::string>& s,
    std::vector<std::string>& t,
    std::set<AlignPoint>& a,
    std::ostream& os)
{
  std::stringstream encodedTargetPhrase;

  std::vector<std::vector<size_t> > a2(t.size());
  for(std::set<AlignPoint>::iterator it = a.begin(); it != a.end(); it++)
    a2[it->second].push_back(it->first);

  for(size_t i = 0; i < t.size(); i++) {
    unsigned idxTarget = GetOrAddTargetSymbolId(t[i]);
    unsigned encodedSymbol = -1;

    unsigned bestSrcPos = s.size();
    unsigned bestDiff = s.size();
    unsigned bestRank = m_lexicalTable.size();
    unsigned badRank = m_lexicalTable.size();

    for(std::vector<size_t>::iterator it = a2[i].begin(); it != a2[i].end(); it++) {
      unsigned idxSource = GetSourceSymbolId(s[*it]);
      size_t r = GetRank(idxSource, idxTarget);
      if(r != badRank) {
        if(r < bestRank) {
          bestRank = r;
          bestSrcPos = *it;
          bestDiff = abs(*it-i);
        } else if(r == bestRank && unsigned(abs(*it-i)) < bestDiff) {
          bestSrcPos = *it;
          bestDiff = abs(*it-i);
        }
      }
    }

    if(bestRank != badRank && bestSrcPos < s.size()) {
      if(bestSrcPos == i)
        encodedSymbol = EncodeREncSymbol3(bestRank);
      else
        encodedSymbol = EncodeREncSymbol2(bestSrcPos, bestRank);
      a.erase(AlignPoint(bestSrcPos, i));
    } else {
      encodedSymbol = EncodeREncSymbol1(idxTarget);
    }

    os.write((char*)&encodedSymbol, sizeof(encodedSymbol));
    m_symbolCounter.Increase(encodedSymbol);
  }

  unsigned stopSymbolId = GetTargetSymbolId(m_phraseStopSymbol);
  unsigned encodedSymbol = EncodeREncSymbol1(stopSymbolId);
  os.write((char*)&encodedSymbol, sizeof(encodedSymbol));
  m_symbolCounter.Increase(encodedSymbol);
}
开发者ID:dynotes,项目名称:mosesdecoder,代码行数:54,代码来源:PhraseTableCreator.cpp

示例14: IncreaseRank

/// increase rank
void nofActiveSoldier::IncreaseRank()
{   
	//max rank reached? -> dont increase!
	if(GetRank() >= gwg->GetGGS().GetMaxMilitaryRank())
		return;

    // Einen Rang höher
    // Inventur entsprechend erhöhen und verringern
    gwg->GetPlayer(player).DecreaseInventoryJob(job_, 1);
    job_ = Job(unsigned(job_) + 1);
    gwg->GetPlayer(player).IncreaseInventoryJob(job_, 1);
}
开发者ID:vader1986,项目名称:s25client,代码行数:13,代码来源:nofActiveSoldier.cpp

示例15: g_object_get

	void SourceObject::SetupSource ()
	{
		GstElement *src;
		g_object_get (Dec_, "source", &src, nullptr);

		if (!CurrentSource_.ToUrl ().scheme ().startsWith ("http"))
			return;

		std::shared_ptr<void> soupRankGuard (nullptr,
				[&] (void*) -> void
				{
					if (PrevSoupRank_)
					{
						SetSoupRank (PrevSoupRank_);
						PrevSoupRank_ = 0;
					}
				});

		if (!g_object_class_find_property (G_OBJECT_GET_CLASS (src), "user-agent"))
		{
			qDebug () << Q_FUNC_INFO
					<< "user-agent property not found for"
					<< CurrentSource_.ToUrl ()
					<< (QString ("|") + G_OBJECT_TYPE_NAME (src) + "|")
					<< "soup rank:"
					<< GetRank ("souphttpsrc")
					<< "webkit rank:"
					<< GetRank ("webkitwebsrc");
			return;
		}

		const auto& str = QString ("LeechCraft LMP/%1 (%2)")
				.arg (Core::Instance ().GetProxy ()->GetVersion ())
				.arg (gst_version_string ());
		qDebug () << Q_FUNC_INFO
				<< "setting user-agent to"
				<< str;
		g_object_set (src, "user-agent", str.toUtf8 ().constData (), nullptr);
	}
开发者ID:DJm00n,项目名称:leechcraft,代码行数:39,代码来源:sourceobject.cpp


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