当前位置: 首页>>代码示例>>C++>>正文


C++ UtlHashBag::remove方法代码示例

本文整理汇总了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()
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:56,代码来源:UtlHashBagIterator.cpp

示例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], \
                           &notExistContainable \
        } ;

        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
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:60,代码来源:UtlHashBag.cpp

示例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()))
            {
//.........这里部分代码省略.........
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:101,代码来源:UtlHashBagIterator.cpp


注:本文中的UtlHashBag::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。