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


C++ HashMap::empty方法代码示例

本文整理汇总了C++中HashMap::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ HashMap::empty方法的具体用法?C++ HashMap::empty怎么用?C++ HashMap::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HashMap的用法示例。


在下文中一共展示了HashMap::empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testClear

  void testClear ()
  {
    map->put ((char*)"one", 1);

    CPPUNIT_ASSERT_EQUAL (map->empty (), false);

    map->clear ();

    CPPUNIT_ASSERT_EQUAL (map->empty (), true);
  }
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:10,代码来源:test_hashmap.cpp

示例2: get

	const Element* Element::get(const String& symbol) {
		static HashMap<String, const Element*> elements;
		if (elements.empty()) {
			for (Index i = 0; i < ARRAY_LENGTH(ELEMENT_DATA); ++i) {
				elements[ELEMENT_DATA[i].symbol] = ELEMENT_DATA+i;
			}
			elements[ELEMENT_D.symbol] = &ELEMENT_D;
			elements[ELEMENT_T.symbol] = &ELEMENT_T;
		}
		HashMap<String, const Element*>::const_iterator it = elements.find(symbol);
		if (it != elements.end()) {
			return it->second;
		}
		else {
			return NULL;
		}
	}
开发者ID:madlee,项目名称:kuai,代码行数:17,代码来源:Element.cpp

示例3: allocator

static std::string testInit()
{
    PoolAllocator allocator(sizeof(HashMap<int,std::string>::Entry));
    StandardInitializer<std::string> initializer;
    StandardHash<int> hash;
    HashMap<int,std::string>* map;

    map = new HashMap<int,std::string>();
    if( !map->empty() or map->size() != 0 ) {
        return "Size not initialized to 0 (a).";
    }
    delete map;

    map = new HashMap<int,std::string>(100);
    if( !map->empty() or map->size() != 0 ) {
        return "Size not initialized to 0 (b).";
    }
    delete map;

    map = new HashMap<int,std::string>(100, allocator);
    if( !map->empty() or map->size() != 0 ) {
        return "Size not initialized to 0 (c).";
    }
    delete map;

    map = new HashMap<int,std::string>(100, allocator, initializer);
    if( !map->empty() or map->size() != 0 ) {
        return "Size not initialized to 0 (d).";
    }
    delete map;

    map = new HashMap<int,std::string>(100, allocator, initializer, hash);
    if( !map->empty() or map->size() != 0 ) {
        return "Size not initialized to 0 (d).";
    }
    delete map;

    map = new HashMap<int,std::string>(10, allocator, initializer, hash, 0.5);
    if( !map->empty() or map->size() != 0 ) {
        return "Size not initialized to 0 (e).";
    } else if( map->loadFactor() != 0.5 ) {
        //printf("%f\n", map->loadFactor());
        std::cout << map->loadFactor() << std::endl;
        return "LoadFactor not properly initialized.";
    }
    delete map;

    return "";
}
开发者ID:staticimport,项目名称:promotelib,代码行数:49,代码来源:HashMapTest.cpp

示例4: testEmpty

 void testEmpty ()
 {
   CPPUNIT_ASSERT_EQUAL (map->empty (), true);
   map->put ((char*)"key", 0);
   CPPUNIT_ASSERT_EQUAL (map->empty (), false);
 }
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:6,代码来源:test_hashmap.cpp


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