本文整理汇总了C++中CList::Remove方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::Remove方法的具体用法?C++ CList::Remove怎么用?C++ CList::Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CList
的用法示例。
在下文中一共展示了CList::Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SortByDepth
void CWorld::SortByDepth(CDesktop* desktop)
{
int i, degree = objectList.GetDegree();
if(!degree) return;
CComponent3D* object;
double m[16];
double* depthList;
CVirtualWebCam* vWebCam;
depthList = new double[degree];
int* idList = new int[degree];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if(CARDeskTop::mode == CARDeskTop::kAR) {
arglCameraViewRH(desktop->trans, m, VIEW_SCALEFACTOR);
glLoadMatrixd(m);
glMultMatrixd(matrix);
} else if(CARDeskTop::mode == CARDeskTop::kVR) {
glLoadMatrixd(matrix);
vWebCam = (CVirtualWebCam*) CARDeskTop::arDeskTop->window->webCamList[0];
}
objectList.GoToFirst();
for(i = 0; i < degree; i++) {
object = (CComponent3D*) objectList.GetKey();
idList[i] = object->GetID();
glPushMatrix();
glMultMatrixd(object->matrix);
glGetDoublev(GL_MODELVIEW_MATRIX, m);
if(CARDeskTop::mode == CARDeskTop::kAR) {
depthList[i] = m[12] * m[12] + m[13] * m[13] + m[14] * m[14];
} else if(CARDeskTop::mode == CARDeskTop::kVR) {
depthList[i] = -(vWebCam->newPos[0] * m[12] + vWebCam->newPos[1] * m[13] + vWebCam->newPos[2] * m[14]);
// depthList[i] = -m[14];
}
glPopMatrix();
objectList.GoToNext();
}
glPopMatrix();
BubbleSortd(depthList, idList, degree);
CList list;
int j, degree2;
objectList.MoveAllLinkTo(&list);
for(i = 0; i < degree; i++) {
list.GoToFirst();
degree2 = list.GetDegree();
for(j = 0; j < degree2; j++) {
object = (CComponent3D*) list.GetKey();
if(idList[i] == object->GetID()) {
objectList.Push(list.Remove(object));
break;
}
list.GoToNext();
}
}
delete depthList;
delete idList;
}
示例2:
//---------------------------------------------------------------------------
// @function:
// CListTest::EresUnittest_Basics
//
// @doc:
// Various list operations
//
//---------------------------------------------------------------------------
GPOS_RESULT
CListTest::EresUnittest_Basics()
{
// create memory pool
CAutoMemoryPool amp;
IMemoryPool *pmp = amp.Pmp();
CList<SElem> listFwd;
listFwd.Init(GPOS_OFFSET(SElem, m_linkFwd));
CList<SElem> listBwd;
listBwd.Init(GPOS_OFFSET(SElem, m_linkBwd));
ULONG cSize = 10;
SElem *rgelem = GPOS_NEW_ARRAY(pmp, SElem, cSize);
GPOS_ASSERT(0 == listFwd.UlSize());
GPOS_ASSERT(0 == listBwd.UlSize());
// insert all elements
for(ULONG i = 0; i < cSize; i++)
{
GPOS_ASSERT(i == listFwd.UlSize());
GPOS_ASSERT(i == listBwd.UlSize());
listFwd.Prepend(&rgelem[i]);
listBwd.Append(&rgelem[i]);
}
GPOS_ASSERT(cSize == listFwd.UlSize());
GPOS_ASSERT(cSize == listBwd.UlSize());
// remove first/last element until empty
for(ULONG i = 0; i < cSize; i++)
{
GPOS_ASSERT(cSize - i == listFwd.UlSize());
GPOS_ASSERT(&rgelem[i] == listFwd.PtLast());
listFwd.Remove(listFwd.PtLast());
// make sure it's still in the other list
GPOS_ASSERT(GPOS_OK == listBwd.EresFind(&rgelem[i]));
}
GPOS_ASSERT(NULL == listFwd.PtFirst());
GPOS_ASSERT(0 == listFwd.UlSize());
// insert all elements in reverse order,
// i.e. list is in same order as array
for(ULONG i = cSize; i > 0; i--)
{
GPOS_ASSERT(cSize - i == listFwd.UlSize());
listFwd.Prepend(&rgelem[i - 1]);
}
GPOS_ASSERT(cSize == listFwd.UlSize());
for(ULONG i = 0; i < cSize; i++)
{
listFwd.Remove(&rgelem[(cSize/2 + i) % cSize]);
}
GPOS_ASSERT(NULL == listFwd.PtFirst());
GPOS_ASSERT(NULL == listFwd.PtLast());
GPOS_ASSERT(0 == listFwd.UlSize());
GPOS_DELETE_ARRAY(rgelem);
return GPOS_OK;
}