本文整理汇总了C++中xr_vector::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ xr_vector::insert方法的具体用法?C++ xr_vector::insert怎么用?C++ xr_vector::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xr_vector
的用法示例。
在下文中一共展示了xr_vector::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: highlight_ammo_for_weapon
void CUIActorMenu::highlight_ammo_for_weapon( PIItem weapon_item, CUIDragDropListEx* ddlist )
{
VERIFY( weapon_item );
VERIFY( ddlist );
static xr_vector<shared_str> ammo_types;
ammo_types.clear_not_free();
CWeapon* weapon = smart_cast<CWeapon*>(weapon_item);
if ( !weapon )
{
return;
}
ammo_types.assign( weapon->m_ammoTypes.begin(), weapon->m_ammoTypes.end() );
CWeaponMagazinedWGrenade* wg = smart_cast<CWeaponMagazinedWGrenade*>(weapon_item);
if ( wg )
{
if ( wg->IsGrenadeLauncherAttached() && wg->m_ammoTypes2.size() )
{
ammo_types.insert( ammo_types.end(), wg->m_ammoTypes2.begin(), wg->m_ammoTypes2.end() );
}
}
if ( ammo_types.size() == 0 )
{
return;
}
xr_vector<shared_str>::iterator ite = ammo_types.end();
u32 const cnt = ddlist->ItemsCount();
for ( u32 i = 0; i < cnt; ++i )
{
CUICellItem* ci = ddlist->GetItemIdx(i);
PIItem item = (PIItem)ci->m_pData;
if ( !item )
{
continue;
}
CWeaponAmmo* ammo = smart_cast<CWeaponAmmo*>(item);
if ( !ammo )
{
highlight_addons_for_weapon( weapon_item, ci );
continue; // for i
}
shared_str const& ammo_name = item->object().cNameSect();
xr_vector<shared_str>::iterator itb = ammo_types.begin();
for ( ; itb != ite; ++itb )
{
if ( ammo_name._get() == (*itb)._get() )
{
ci->m_select_armament = true;
break; // itb
}
}
}//for i
}
示例2: transfer
void transfer(const char *name, xr_vector<T> &dest, IReader& F, u32 chunk)
{
IReader* O = F.open_chunk(chunk);
u32 count = O?(O->length()/sizeof(T)):0;
clMsg ("* %16s: %d",name,count);
if (count)
{
dest.reserve(count);
dest.insert (dest.begin(), (T*)O->pointer(), (T*)O->pointer() + count);
}
if (O) O->close ();
}
示例3: if
void sort_tlist_mat
(
xr_vector<mapMatrixTextures::TNode*,render_alloc<mapMatrixTextures::TNode*> >& lst,
xr_vector<mapMatrixTextures::TNode*,render_alloc<mapMatrixTextures::TNode*> >& temp,
mapMatrixTextures& textures,
BOOL bSSA
)
{
int amount = textures.begin()->key->size();
if (bSSA)
{
if (amount<=1)
{
// Just sort by SSA
textures.getANY_P (lst);
std::sort (lst.begin(), lst.end(), cmp_textures_ssa_mat);
}
else
{
// Split into 2 parts
mapMatrixTextures::TNode* _it = textures.begin ();
mapMatrixTextures::TNode* _end = textures.end ();
for (; _it!=_end; _it++) {
if (_it->val.ssa > r_ssaHZBvsTEX) lst.push_back (_it);
else temp.push_back (_it);
}
// 1st - part - SSA, 2nd - lexicographically
std::sort (lst.begin(), lst.end(), cmp_textures_ssa_mat);
if (2==amount) std::sort (temp.begin(), temp.end(), cmp_textures_lex2_mat);
else if (3==amount) std::sort (temp.begin(), temp.end(), cmp_textures_lex3_mat);
else std::sort (temp.begin(), temp.end(), cmp_textures_lexN_mat);
// merge lists
lst.insert (lst.end(),temp.begin(),temp.end());
}
}
else
{
textures.getANY_P (lst);
if (2==amount) std::sort (lst.begin(), lst.end(), cmp_textures_lex2_mat);
else if (3==amount) std::sort (lst.begin(), lst.end(), cmp_textures_lex3_mat);
else std::sort (lst.begin(), lst.end(), cmp_textures_lexN_mat);
}
}
示例4: stats
IC void CSmartCastStats::show ()
{
if (m_stats.empty()) {
Msg ("CONGRATULATIONS : SmartCast stats is empty!!!");
return;
}
m_temp.clear ();
m_temp.insert (m_temp.begin(),m_stats.begin(),m_stats.end());
std::sort (m_temp.begin(),m_temp.end(),CStatsPredicate());
u32 total = 0;
xr_vector<CStats>::const_iterator I = m_temp.begin();
xr_vector<CStats>::const_iterator E = m_temp.end();
for ( ; I != E; ++I)
total += (*I).m_count;
Msg ("SmartCast stats (different %d, total %d) : ",(u32)m_stats.size(),total);
I = m_temp.begin();
for ( ; I != E; ++I)
Msg ("%8d %6.2f% : smart_cast<%s>(%s)",(*I).m_count,float((*I).m_count)*100.f/float(total),(*I).m_to,(*I).m_from);
}
示例5:
void ProcessOne (u32 Base, u32 limit=8)
{
BestQuad.clear ();
BestQuad_Count = 0;
// ***** build horizontal line
vecDW BaseLine;
BaseLine.reserve(limit*2);
u32 BL_Left=0,BL_Right=0;
// middle
vertex& BaseNode = g_nodes[Base];
BaseLine.push_back(Base);
// left expansion
for (;;) {
vertex& B = g_nodes[BaseLine.front()];
u32 LP = B.nLeft();
if (BL_Left>limit) break;
if (LP==InvalidNode) break;
if (used[LP]) break;
if (!NodeSimilar(BaseNode,g_nodes[LP])) break;
BL_Left ++;
BaseLine.insert(BaseLine.begin(),LP);
}
// right expansion
for (;;) {
vertex& B = g_nodes[BaseLine.back()];
u32 RP = B.nRight();
if (BL_Right>limit) break;
if (RP==InvalidNode) break;
if (used[RP]) break;
if (!NodeSimilar(BaseNode,g_nodes[RP])) break;
BL_Right++;
BaseLine.push_back(RP);
}
// main cycle
// Msg("- ---");
u32 BasePos = BaseLine[BL_Left];
for (u32 left=0; left<=BL_Left; left++)
{
u32 limit_right = left+limit-1;
if (limit_right>=BaseLine.size()) limit_right=BaseLine.size()-1;
u32 limit_left = left;
if (limit_left<BL_Left) limit_left = BL_Left;
if (limit_left>limit_right) limit_left = limit_right;
for (int right=int(limit_right); right>=int(limit_left); right--)
{
// now we have range [left,right]
// expand it up and down
xr_vector<vecDW> stack_up;
xr_vector<vecDW> stack_down;
// Msg("[%2d,%2d], %d", left,right,BaseLine.size());
stack_up.reserve (limit);
stack_up.push_back (vecDW());
stack_up.back().assign (BaseLine.begin()+left,BaseLine.begin()+right+1);
stack_down.reserve (limit);
stack_down.push_back (vecDW());
stack_down.back().assign(BaseLine.begin()+left,BaseLine.begin()+right+1);
// expand up
for (;stack_up.size()<=limit;) {
// create _new list
stack_up.push_back (vecDW());
vecDW& src = stack_up[stack_up.size()-2];
vecDW& dest = stack_up[stack_up.size()-1];
dest.reserve (limit);
BOOL bFailed = FALSE;
// iterate on it
vecDW_it I = src.begin ();
vecDW_it E = src.end ();
for (; I!=E; I++)
{
u32 id = g_nodes[*I].nForward();
if (id==InvalidNode) { bFailed=TRUE; break; }
if (used[id]) { bFailed=TRUE; break; }
if (!NodeSimilar(g_nodes[id],BaseNode)){ bFailed=TRUE; break; }
dest.push_back (id);
}
if (bFailed) {
stack_up.pop_back();
break;
}
}
// expand down
for (; (stack_up.size()+stack_down.size()-1) <= limit;) {
// create _new list
stack_down.push_back(vecDW());
vecDW& src = stack_down[stack_down.size()-2];
vecDW& dest = stack_down[stack_down.size()-1];
dest.reserve (limit);
//.........这里部分代码省略.........