本文整理汇总了C++中CList::EresFind方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::EresFind方法的具体用法?C++ CList::EresFind怎么用?C++ CList::EresFind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CList
的用法示例。
在下文中一共展示了CList::EresFind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//---------------------------------------------------------------------------
// @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;
}