本文整理汇总了C++中HashTable::count方法的典型用法代码示例。如果您正苦于以下问题:C++ HashTable::count方法的具体用法?C++ HashTable::count怎么用?C++ HashTable::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashTable
的用法示例。
在下文中一共展示了HashTable::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(HashTableTest, expandKey) {
HashTable<std::string,std::string> ht;
char buf[10];
std::string c;
for(int i = 0; i < 100; i ++)
{
sprintf(buf,"a%d",i);
//ht.add(buf, "ab");
ht[buf] = "ab";
ht[buf] = "ac";
c = ht[buf];
std::cout << "buf:" << buf << ",value:" << ht[buf] << ",c:" << c << std::endl;
}
//std::cout << "11:" << ht["11"]<< std::endl;
EXPECT_EQ(100UL,ht.count());
ht.remove("a8");
EXPECT_EQ(99UL,ht.count());
//EXPECT_TRUE(ht["a13"] == "ac");
EXPECT_TRUE(ht.containsKey("a13"));
EXPECT_TRUE(ht.contains("a13","ac"));
EXPECT_FALSE(ht.containsKey("a1012"));
EXPECT_FALSE(ht.contains("a1123","ac"));
EXPECT_FALSE(ht.contains("a12","ab"));
for(int i = 0; i < 1000; i ++)
{
sprintf(buf,"a%d",i);
//ht.add(buf, "ab");
ht[buf] = "ab";
ht[buf] = "ac";
c = ht[buf];
std::cout << "buf:" << buf << ",value:" << ht[buf] << ",c:" << c << std::endl;
}
ht.remove("a18");
EXPECT_EQ(999UL,ht.count());
//EXPECT_TRUE(ht["a13"] == "ac");
EXPECT_TRUE(ht.containsKey("a13"));
EXPECT_TRUE(ht.contains("a13","ac"));
EXPECT_TRUE(ht.containsKey("a112"));
EXPECT_FALSE(ht.contains("a1203","ac"));
}