本文整理汇总了C++中UtlHashBag::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ UtlHashBag::remove方法的具体用法?C++ UtlHashBag::remove怎么用?C++ UtlHashBag::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UtlHashBag
的用法示例。
在下文中一共展示了UtlHashBag::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeKey
/*!a test case for the interaction of remove() and key().
*/
void removeKey()
{
UtlString v1("a");
UtlString v2("b");
UtlString v3("c");
UtlString v4("d");
UtlContainable* e;
UtlHashBag h;
h.insert(&v1);
h.insert(&v2);
h.insert(&v3);
h.insert(&v4);
UtlHashBagIterator iter(h);
// Check that key() returns NULL in the initial state.
CPPUNIT_ASSERT(iter.key() == NULL);
// Step the iterator and check that key() returns non-NULL.
e = iter();
CPPUNIT_ASSERT(e != NULL);
CPPUNIT_ASSERT(iter.key() != NULL);
// Delete the element and check that key() returns NULL.
h.remove(e);
CPPUNIT_ASSERT(iter.key() == NULL);
// Step the iterator and check that key() returns non-NULL.
e = iter();
CPPUNIT_ASSERT(e != NULL);
CPPUNIT_ASSERT(iter.key() != NULL);
// Step the iterator and check that key() returns non-NULL.
e = iter();
CPPUNIT_ASSERT(e != NULL);
CPPUNIT_ASSERT(iter.key() != NULL);
// Delete the element and check that key() returns NULL.
h.remove(e);
CPPUNIT_ASSERT(iter.key() == NULL);
// Step the iterator and check that key() returns non-NULL.
e = iter();
CPPUNIT_ASSERT(e != NULL);
CPPUNIT_ASSERT(iter.key() != NULL);
// Step the iterator after the last element and check that
// key() returns NULL.
e = iter();
CPPUNIT_ASSERT(e == NULL);
CPPUNIT_ASSERT(iter.key() == NULL);
} //removeKey()
示例2: testRemove
/*!a Test case for testRemove()
*
* The Test data for this test case is
* a) is an entry's reference
* b) is an entry's value(not reference)
* c) is the first of multiple matches and is the value match
* d) is the second of multiple matches.
* e) has no match at all
*/
void testRemove()
{
int testCount = 4 ;
const char* prefix = "test the remove(UtlContainable* c) method where c " ;
const char* Msgs[] = { \
"is an entry's reference ", \
"is an entry's value(not reference) ", \
"is first of multiple value matches ", \
"has no match at all " \
} ;
const char* suffix1 = " :- Verify returned value" ;
const char* suffix2 = " :- Verify total entries" ;
// Insert a new value such that its value matches(isEqual to)
// one of the existing items
commonList.insert(commonContainables_Clone[4]) ;
UtlString notExistContainable("This cannot and willnot exist");
UtlContainable* dataForRemove[] = { \
commonContainables[0], \
commonContainables_Clone[2], \
commonContainables[4], \
¬ExistContainable \
} ;
int totalEnt = commonEntriesCount + 1;
UtlBoolean expectedReturnValues[] = { \
true, true, true, false \
} ;
int entriesValue[] = { --totalEnt, --totalEnt, --totalEnt, totalEnt } ;
totalEnt = commonEntriesCount + 1;
for (int i = 0 ; i < testCount ; i++)
{
string msg ;
TestUtilities::createMessage(3, &msg, prefix, Msgs[i], suffix1) ;
UtlContainable* retValue ;
retValue = commonList.remove(dataForRemove[i]) ;
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), (UtlBoolean)(retValue!=NULL), \
(UtlBoolean)expectedReturnValues[i]) ;
TestUtilities::createMessage(3, &msg, prefix, Msgs[i], suffix2) ;
int expCount = (int)commonList.entries() ;
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), entriesValue[i], expCount) ;
}
} //testRemove
示例3: testFiltered
void testFiltered()
{
UtlString key1a("key1");
UtlString key1b("key1");
UtlString key2("key2");
UtlString key3("key3");
UtlHashBag theBag;
theBag.insert(&key1a);
theBag.insert(&key1b);
theBag.insert(&key2);
theBag.insert(&key3);
UtlString* content;
{
UtlString filter("key2");
UtlHashBagIterator each(theBag,&filter);
int foundMask;
foundMask = 0;
while ((content = (UtlString*)each()))
{
if ( &key1a == content )
{
CHECK_FOUND(foundMask,0x0001);
}
else if ( &key1b == content )
{
CHECK_FOUND(foundMask,0x0002);
}
else if ( &key2 == content )
{
CHECK_FOUND(foundMask,0x0004);
}
else if ( &key3 == content )
{
CHECK_FOUND(foundMask,0x0008);
}
else
{
CPPUNIT_FAIL("Unknown element returned");
}
}
CPPUNIT_ASSERT_MESSAGE("Expected element not found",0x0004==foundMask);
}
{
UtlString filter("key1");
UtlHashBagIterator each(theBag,&filter);
int foundMask;
foundMask = 0;
while ((content = (UtlString*)each()))
{
if ( &key1a == content )
{
CHECK_FOUND(foundMask,0x0001);
}
else if ( &key1b == content )
{
CHECK_FOUND(foundMask,0x0002);
}
else if ( &key2 == content )
{
CHECK_FOUND(foundMask,0x0004);
}
else if ( &key3 == content )
{
CHECK_FOUND(foundMask,0x0008);
}
else
{
CPPUNIT_FAIL("Unknown element returned");
}
}
CPPUNIT_ASSERT_MESSAGE("Expected element not found",0x0003==foundMask);
}
{
UtlString filter("key1");
UtlHashBagIterator each(theBag,&filter);
int foundMask;
foundMask = 0;
UtlString* removed = (UtlString*)theBag.remove(&filter);
if ( &key1a == removed )
{
CHECK_FOUND(foundMask,0x0001);
}
else if ( &key1b == removed )
{
CHECK_FOUND(foundMask,0x0002);
}
else
{
CPPUNIT_FAIL("Unknown element removed");
}
while ((content = (UtlString*)each()))
{
//.........这里部分代码省略.........