本文整理汇总了C++中CArray::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::Size方法的具体用法?C++ CArray::Size怎么用?C++ CArray::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::Size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StoreExcerptPriorityTerms
// This creates the list of excerpt terms that are later stored in the ab_tree.
// @param doc_id - this is the doc id of the excerpt
void StoreExcerptPriorityTerms(_int64 &doc_id) {
uChar size = (uChar)m_tok_queue.Size();
int ovf_size = sizeof(S5Byte) + sizeof(uLong) + sizeof(uChar);
ovf_size += (sizeof(S5Byte) + sizeof(uChar)) * m_tok_queue.Size();
m_excerpt_file.AskBufferOverflow(ovf_size);
m_excerpt_file.WriteCompObject5Byte(doc_id);
m_excerpt_file.WriteCompObject(size);
m_tok_queue.CopyNodesToBuffer(m_sorted_tok_set);
CSort<STokenPtr> sort(m_sorted_tok_set.Size(), CompareTermPosition);
sort.HybridSort(m_sorted_tok_set.Buffer());
for(int i=0; i<m_sorted_tok_set.Size(); i++) {
SToken &ptr = *m_sorted_tok_set[i].ptr;
int id = m_duplicate_term.FindWord((char *)&ptr.word_id, sizeof(S5Byte));
ptr.assoc_num <= 3;
ptr.assoc_num |= m_term_occurr[id];
m_excerpt_file.WriteCompObject(ptr.word_id);
m_excerpt_file.WriteCompObject(ptr.occur);
m_excerpt_file.WriteCompObject(ptr.term_weight);
m_excerpt_file.WriteCompObject(ptr.assoc_num);
}
}
示例2: GetPave
int CoreScript::GetPave()
{
if (pave) {
return pave;
}
// OLD: Pavement is used as a flag for "this is a road" by the AI.
// It's important to use the least common pave in a domain
// so that building isn't interfered with.
// NOW: Just use least common pave to spread things out.
CArray<int, WorldGrid::NUM_PAVE> nPave;
for (int i = 0; i < WorldGrid::NUM_PAVE; ++i) nPave.Push(0);
if (pave == 0) {
Rectangle2I inner = InnerSectorBounds(ToSector(parentChit->Position()));
for (Rectangle2IIterator it(inner); !it.Done(); it.Next()) {
const WorldGrid& wg = Context()->worldMap->GetWorldGrid(it.Pos());
nPave[wg.Pave()] += 1;
}
}
nPave[0] = 0;
int maxPave = nPave[nPave.FindMax(0, [](int, int count) { return count; })];
if (maxPave == 0) {
pave = 1 + parentChit->random.Rand(WorldGrid::NUM_PAVE - 1);
}
else {
pave = 1 + ArrayFindMax(nPave.Mem()+1, nPave.Size() - 1, 0, [](int, int count) { return -count; });
}
GLASSERT(pave > 0 && pave < nPave.Size());
if (pave == 0) {
pave = 1;
}
return pave;
}
示例3: main
int main()
{
CArray arr;
char* str = new char[MAX_LENGTH];
cin >> str;
while(!cin.eof()) {
arr.Add(str);
cin >> str;
}
//сортируем
MSDSort(arr);
for(int i = 0; i < arr.Size(); i++) {
cout << arr[i] << endl;
}
delete[] str;
return 0;
}
示例4: CreateSpiderList
// This creates the final set of ranked urls
void CreateSpiderList(CArray<SRankURLPtr> &ptr_buff) {
m_spider_list_file.OpenWriteFile(CUtility::ExtendString
("GlobalData/SpiderList/fin_spider_list", GetClientID()));
int list_num = 0;
int offset = 0;
while(list_num < m_spider_num && offset < ptr_buff.Size()) {
SRankURL *ptr = ptr_buff[offset++].ptr;
if(m_domain_occur[ptr->domain_id] < 25) {
char *url = m_url_buff.Buffer() + m_url_offset[ptr->url_id];
int url_length = m_url_offset[ptr->url_id+1] - m_url_offset[ptr->url_id];
m_spider_list_file.WriteCompObject(url_length);
m_spider_list_file.WriteCompObject(url, url_length);
m_domain_occur[ptr->domain_id]++;
list_num++;
}
}
}
示例5: Calc
void Web::Calc(const Vector2I* exclude)
{
static Vector2I origin = { NUM_SECTORS / 2, NUM_SECTORS / 2 };
CArray<Vector2I, NUM_SECTORS * NUM_SECTORS> cores;
cores.Push(origin);
int n = 0;
CoreScript** list = CoreScript::GetCoreList(&n);
for (int i = 0; i < n; ++i) {
CoreScript* cs = list[i];
Vector2I sector = ToSector(cs->ParentChit()->Position());
if ( (sector != origin) && cs && cs->InUse()
&& Team::Instance()->GetRelationship(cs->ParentChit()->Team(), TEAM_VISITOR) != ERelate::ENEMY)
{
GLASSERT(cores.HasCap());
if (!exclude || (*exclude != sector)) {
cores.Push(sector);
}
}
}
tree.Calc(cores.Mem(), cores.Size());
}
示例6: CheckIf
bool CElement::CheckIf(CIfData *pIfData, const CParameters *paParameters) const
{
if(pIfData->m_Find)
{
CParameters aSearchParameters;
for(CArray<CExpression>::CIterator p = pIfData->m_aSearchParameters.GetIterator(); p.Exists(); p.Next())
aSearchParameters.Add(ComputeValue(p.Get(), paParameters));
CArray<CElement *> apElements;
m_pDatabase->SearchElements(pIfData->m_ElementType, pIfData->m_ElementModelName, pIfData->m_SearchFunction, &aSearchParameters, &apElements);
bool True = apElements.Size() > 0;
#ifdef SPB_DEBUG
printf("success: condition find %d\n", True);
#endif
return True;
}
else
{
bool True = ComputeValue(pIfData->m_Expression, paParameters) != 0;
#ifdef SPB_DEBUG
printf("success: condition %d\n", True);
#endif
return True;
}
}
示例7: DoPicking
void CEffectsGame::DoPicking()
{
bool hit = false;
Vector3 tileHitPos;
SMapTile *tileHit;
Vector3 start = pCamera->GetWorldPosition();
Vector3 end = start + pCamera->forward * 1000.0f;
Vector3 pos;
pLevel->UnHighlightTile();
// find tile we are pointing at
if (hit = pLevel->CastRay(start, end, OUT tileHitPos, OUT &tileHit, OUT &pos))
{
pLevel->HighlightTile(tileHitPos.x, tileHitPos.y, tileHitPos.z);
}
static float force = 10;
if (gInput.WasKeyPressed(K_PGUP)) force += 5.0f;
if (gInput.WasKeyPressed(K_PGDN)) force -= 5.0f;
//gVGUI.AddTextMessage(300,200,WHITE,"Force: %f",force);
//car->pBarrel->DrawAxis();
// shooting - delete tile
if (gInput.IsKeydown(K_MOUSE1))
{
static float delay = 0;
delay += frametime;
if (delay > 0.05f)
{
// shoot a bullet
CreateBullet(car->pBarrel->GetWorldPosition(), car->pBarrel->up);
float puffSpeed = 0.35;
// add puff effect
for (int i = 0; i<3; i++)
{
static CTexture *puffTex = new CTexture("particles/explosion4.dds");
CParticle *p = new CParticle(puffTex);
p->size = Vector2(0.15, 0.15);
p->position = car->pBarrel->GetWorldPosition() + car->pBarrel->up/2;
p->velocity = Vector3( frand(-puffSpeed,puffSpeed), frand(-puffSpeed,puffSpeed)+1, frand(-puffSpeed,puffSpeed) );
//p->gravity = -10;
p->lifetime = 0.25;
p->color = SRGBA(255,255,255,50);
p->sizeVel = Vector2(1,1);
p->colorChange = SRGBA(255,255,255,0);
particles->Add(p);
}
// add muzzle flash
static CTexture *muzzleTex[] = {
new CTexture("particles/flame1.dds"),
new CTexture("particles/explosion1.dds")
};
{
CParticle *p = new CParticle(muzzleTex[rand()%2]);
p->size = Vector2(0.7, 0.7);
p->position = car->pBarrel->GetWorldPosition() + car->pBarrel->up/2;
p->lifetime = 0.01;
p->additive = true;
//p->color = SRGBA(255,255,255,50);
//p->sizeVel = Vector2(1,1);
//p->colorChange = SRGBA(255,255,255,0);
particles->Add(p);
}
delay = 0;
// if hit a tile, destroy it
/* if (hit)
{
EnterCriticalSection(&renderCS);
tileHit->type = 0;
LeaveCriticalSection(&renderCS);
SMapChunk *chunk = pLevel->GetChunk(
floor(tileHitPos.x/SMapChunk::Size),
floor(tileHitPos.y/SMapChunk::Size),
floor(tileHitPos.z/SMapChunk::Size) );
chunk->dirtyBody = true;
chunk->dirty = true;
//pLevel->UpdateTile(tileHitPos.x, tileHitPos.y, tileHitPos.z);
SSpawnTile s;
s.pos = tileHitPos;
s.vel = pCamera->forward * force;
boxesToSpawn.push(s);
// create a physical entity in this place
/*NewtonBody *box = AddBox(pScene, pWorld, tileHitPos+Vector3(0.5, 0.5, 0.5), Vector3(0.95f,0.95f,0.95f), Vector3(), 100);
// add some velocity
//.........这里部分代码省略.........
示例8: MSDSort
void MSDSort(CArray &arr)
{
countSortSym(arr, 0, 0, arr.Size());
}
示例9: Explode
void CRocket::Explode()
{
Vector3 pos = GetPosition();
int x = pos.x;
int y = pos.y;
int z = pos.z;
int r = 3;
this->Remove(light);
CArray<CEntity*> enemies;
pGame->FindEntitiesByTypeInRange("Enemy", GetWorldPosition(), 5, OUT enemies);
for (int i=0; i<enemies.Size(); i++)
enemies[i]->hp -= 80;
// destroy tiles in the area
/*for (int ix = x, xsign = 1, xstep = 1;
(ix >= x - r) && (ix <= x + r);
ix += xsign * xstep, xsign = -xsign, xstep++)
for (int iy = y, ysign = 1, ystep = 1;
(iy >= y - r) && (iy <= y + r);
iy += ysign * ystep, ysign = -ysign, ystep++)
for (int iz = z, zsign = 1, zstep = 1;
(iz >= z - r) && (iz <= z + r);
iz += zsign * zstep, zsign = -zsign, zstep++)
{
SMapTile *tile = NULL;
if ((tile = pLevel->GetTile(ix,iy,iz)) == NULL) continue;
if (tile->type == 0) continue;
tile->type = 0;
SMapChunk *chunk = pLevel->GetChunk(
floor((float)ix/SMapChunk::Size),
floor((float)iy/SMapChunk::Size),
floor((float)iz/SMapChunk::Size) );
chunk->dirtyBody = true;
chunk->dirty = true;
SSpawnTile s;
s.pos = Vector3(ix,iy,iz);
s.vel = (Vector3(ix+frand(-0.25f,+0.25),iy+frand(-0.25f,+0.25),iz+frand(-0.25f,+0.25)) - pos).Normalize() * cv_explosionout.GetFloat() + (-forward)*cv_explosionforce.GetFloat();
//CEffectsGame::pInstance->SpawnTile(s);
}
*/
// add particle effect
static CTexture *expTex = CTexture::Get("particles/flamer.dds");
CParticle *p = new CParticle(expTex);
p->position = pos;
p->size = Vector2(10,10);
p->sizeVel = Vector2(15,15);
p->rotationVel = 90;
p->colorChange = SRGBA(255,255,255,100);
p->colorTime = 10;
p->lifetime = 5;
p->additive = true;
p->depthWrite = false;
pGame->particles->Add(p);
p = new CParticle(expTex);
p->position = pos;
p->size = Vector2(8,8);
p->sizeVel = Vector2(10,10);
p->rotationVel = 90;
p->colorChange = SRGBA(22,22,22,100);
p->colorTime = 5;
p->lifetime = 5;
p->additive = true;
p->depthWrite = false;
pGame->particles->Add(p);
}
示例10: Trace
SCollisionResult CMovement::Trace( CArray<STriangle> &triangles, Vector3 start, Vector3 bboxMax, Vector3 boxdir[3], Vector3 displacement )
{
float fraction = 1.0f;
SCollisionResult trace, closest;
float dist, mindist = 99999.0f;
CArray<STriangle> colliding;
ZeroMemory(&closest, sizeof(closest));
ZeroMemory(&trace, sizeof(trace));
// Find the collisions with the closest triangles
for (int i=0; i<triangles.Size(); i++)
{
STriangle &t = triangles[i];
CArray<Vector3> vlist;
vlist.AddToTail(t.v[0]);
vlist.AddToTail(t.v[1]);
vlist.AddToTail(t.v[2]);
if ( CCollision::OBBPolygon( vlist, start, bboxMax, boxdir, displacement, OUT trace ) )
{
if ( trace.fraction <= fraction + 0.1f )
{
//if ( trace.fraction < fraction + 0.1f ) colliding.Clear();
// check if all points of our bbox are in front of the face
SPlane plane = SPlane( t.v[0], t.v[1], t.v[2] );
Vector3 size = bboxMax * 2.0f;
Vector3 min = start - bboxMax;
Vector3 max = start + bboxMax;
//Debug("collided: %f %f %f", plane.normal.x, plane.normal.y, plane.normal.z);
if ( plane.GetSide( min, OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
if ( plane.GetSide( max, OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
if ( plane.GetSide( min + Vector3( size.x, 0, 0 ), OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
if ( plane.GetSide( min + Vector3( 0, size.y, 0 ), OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
if ( plane.GetSide( min + Vector3( 0, 0, size.z ), OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
if ( plane.GetSide( max - Vector3( size.x, 0, 0 ), OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
if ( plane.GetSide( max - Vector3( 0, size.y, 0 ), OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
if ( plane.GetSide( max - Vector3( 0, 0, size.z ), OUT dist ) == EPlaneSide::Back ) continue; if ( dist < mindist ) mindist = dist;
fraction = trace.fraction;
closest = trace;
t.normal = -(t.v[2] - t.v[0]).Cross(t.v[1] - t.v[0]).Normalize();
closest.normal = t.normal;
colliding.AddToTail( t ); // add triangle to colliding triangles list
//triangleList.Add( t );
//Debug("COLLIDED!");
}
}
}
Vector3 dir = displacement;
Vector3 normal = closest.normal;
Vector3 endpoint = start;
// If collided, process the collision
if ( fraction < 1 )
{
// OK
float m = 0.005f; // distance from the surface
float f = closest.fraction; // fraction of the full dir distance to the contact point
Vector3 dirNorm = dir; dirNorm.Normalize();
if ( Vector3::Dot( -dir, normal ) != 0 )
{
// PERFECT !!!
float ndir = dir.Length() * (m / Vector3::Dot( -dir, normal ));
float x = (f * dir.Length() - ndir); // distance we move along the dir direction to stay away from the surface
//Debug.WriteLine( "normal: " + closest.normal + " x: " + x + " f: " + f + " ndir: " + ndir + " distance to surf: " + mindist + " ndir.Y: " );
endpoint = start + dirNorm * x;
Vector3 slide = ClipVelocity( dir, closest.normal, 1.00f );
float left = 1.0f - (f - ndir / dir.Length());
closest.slide = slide * left;
}
}
else
endpoint = start + dir;
closest.collision = fraction != 1.0f;
closest.endpoint = endpoint;
return closest;
}