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


C++ KeySet::crbegin方法代码示例

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


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

示例1:

TEST(test_iter, const_iterate)
{
	std::cout << "testing const iterate" << std::endl;
	const KeySet ks2 (5,
		*Key ("user/key2/1", KEY_END),
		*Key ("user/key2/2", KEY_END),
		*Key ("user/key2/3", KEY_VALUE, "value", KEY_END),
		KS_END);

	ASSERT_EQ((*ks2.begin()).getName() ,  "user/key2/1"    ) <<  "name wrong";
	ASSERT_EQ(ks2.begin()->getName() ,  "user/key2/1"      ) <<  "name wrong";
	ASSERT_EQ((ks2.begin()[0])->getName() ,  "user/key2/1"  ) << "name wrong";
	ASSERT_EQ((*(++ks2.begin())).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((++ks2.begin())->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((*(ks2.begin()+1)).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((ks2.begin()+1)->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((ks2.begin()[1])->getName() ,  "user/key2/2"  ) << "name wrong";
	ASSERT_EQ((*(ks2.begin()+2)).getName() ,  "user/key2/3") <<  "name wrong";
	ASSERT_EQ((ks2.begin()+2)->getName() ,  "user/key2/3"  ) <<  "name wrong";
	ASSERT_EQ((ks2.begin()[2])->getName() ,  "user/key2/3"  ) << "name wrong";
	ASSERT_EQ((ks2.begin()+3) ,  ks2.end()  ) <<  "end iterator broken";

	ASSERT_EQ((*ks2.rbegin()).getName() ,  "user/key2/3"    ) <<  "name wrong";
	ASSERT_EQ(ks2.rbegin()->getName() ,  "user/key2/3"      ) <<  "name wrong";
	ASSERT_EQ((ks2.rbegin()[0])->getName() ,  "user/key2/3"  ) << "name wrong";
	ASSERT_EQ((*(++ks2.rbegin())).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((++ks2.rbegin())->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((*(ks2.rbegin()+1)).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((ks2.rbegin()+1)->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((ks2.rbegin()[1])->getName() ,  "user/key2/2"  ) << "name wrong";
	ASSERT_EQ((*(ks2.rbegin()+2)).getName() ,  "user/key2/1") <<  "name wrong";
	ASSERT_EQ((ks2.rbegin()+2)->getName() ,  "user/key2/1"  ) <<  "name wrong";
	ASSERT_EQ((ks2.rbegin()[2])->getName() ,  "user/key2/1"  ) << "name wrong";
	ASSERT_EQ((ks2.rbegin()+3) ,  ks2.rend()  ) <<  "end iterator broken";

	ASSERT_EQ((*ks2.cbegin()).getName() ,  "user/key2/1"    ) <<  "name wrong";
	ASSERT_EQ(ks2.cbegin()->getName() ,  "user/key2/1"      ) <<  "name wrong";
	ASSERT_EQ((ks2.cbegin()[0])->getName() ,  "user/key2/1"  ) << "name wrong";
	ASSERT_EQ((*(++ks2.cbegin())).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((++ks2.cbegin())->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((*(ks2.cbegin()+1)).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((ks2.cbegin()+1)->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((ks2.cbegin()[1])->getName() ,  "user/key2/2"  ) << "name wrong";
	ASSERT_EQ((*(ks2.cbegin()+2)).getName() ,  "user/key2/3") <<  "name wrong";
	ASSERT_EQ((ks2.cbegin()+2)->getName() ,  "user/key2/3"  ) <<  "name wrong";
	ASSERT_EQ((ks2.cbegin()[2])->getName() ,  "user/key2/3"  ) << "name wrong";
	ASSERT_EQ((ks2.cbegin()+3) ,  ks2.cend()  ) <<  "end iterator broken";

	ASSERT_EQ((*ks2.crbegin()).getName() ,  "user/key2/3"    ) <<  "name wrong";
	ASSERT_EQ(ks2.crbegin()->getName() ,  "user/key2/3"      ) <<  "name wrong";
	ASSERT_EQ((ks2.crbegin()[0])->getName() ,  "user/key2/3"  ) << "name wrong";
	ASSERT_EQ((*(++ks2.crbegin())).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((++ks2.crbegin())->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((*(ks2.crbegin()+1)).getName() ,  "user/key2/2") <<  "name wrong";
	ASSERT_EQ((ks2.crbegin()+1)->getName() ,  "user/key2/2"  ) <<  "name wrong";
	ASSERT_EQ((ks2.crbegin()[1])->getName() ,  "user/key2/2"  ) << "name wrong";
	ASSERT_EQ((*(ks2.crbegin()+2)).getName() ,  "user/key2/1") <<  "name wrong";
	ASSERT_EQ((ks2.crbegin()+2)->getName() ,  "user/key2/1"  ) <<  "name wrong";
	ASSERT_EQ((ks2.crbegin()[2])->getName() ,  "user/key2/1"  ) << "name wrong";
	ASSERT_EQ((ks2.crbegin()+3) ,  ks2.crend()  ) <<  "end iterator broken";
}
开发者ID:tryge,项目名称:libelektra,代码行数:61,代码来源:testcpp_iter.cpp


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