本文整理汇总了C++中MapVector::end方法的典型用法代码示例。如果您正苦于以下问题:C++ MapVector::end方法的具体用法?C++ MapVector::end怎么用?C++ MapVector::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapVector
的用法示例。
在下文中一共展示了MapVector::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPointer
// get or create value
Pointer getPointer(Module *M, const char *name, int64_t off)
{
Value *va;
MapVector<TestPointer, Pointer>::iterator E = valueMap.end();
Pointer& p = valueMap[TestPointer(name, off)];
// if the last operation increased the size of valueMap, then
// the pointer does not exist
if (E != valueMap.end()) {
// use always the same llvm value
std::map<const char *, Value *>::iterator VI = llvmValues.find(name);
if (VI == llvmValues.end()) {
if (strcmp(name, "null") == 0)
va = ConstantPointerNull::get(llvm::Type::getInt32PtrTy(M->getContext()));
else
va = new GlobalVariable(*M, IntegerType::get(M->getContext(), 32),
false,
GlobalValue::CommonLinkage, 0 , name);
llvmValues.insert(std::make_pair(name, va));
} else {
va = VI->second;
}
// copy it to map (p is reference)
p = Pointer(va, off);
}
return p;
}
示例2:
TEST(MapVectorTest, insert) {
MapVector<int, int> MV;
std::pair<MapVector<int, int>::iterator, bool> R;
R = MV.insert(std::make_pair(1, 2));
ASSERT_EQ(R.first, MV.begin());
EXPECT_EQ(R.first->first, 1);
EXPECT_EQ(R.first->second, 2);
EXPECT_TRUE(R.second);
R = MV.insert(std::make_pair(1, 3));
ASSERT_EQ(R.first, MV.begin());
EXPECT_EQ(R.first->first, 1);
EXPECT_EQ(R.first->second, 2);
EXPECT_FALSE(R.second);
R = MV.insert(std::make_pair(4, 5));
ASSERT_NE(R.first, MV.end());
EXPECT_EQ(R.first->first, 4);
EXPECT_EQ(R.first->second, 5);
EXPECT_TRUE(R.second);
EXPECT_EQ(MV.size(), 2u);
EXPECT_EQ(MV[1], 2);
EXPECT_EQ(MV[4], 5);
}
示例3:
TEST(MapVectorTest, remove_if) {
MapVector<int, int> MV;
MV.insert(std::make_pair(1, 11));
MV.insert(std::make_pair(2, 12));
MV.insert(std::make_pair(3, 13));
MV.insert(std::make_pair(4, 14));
MV.insert(std::make_pair(5, 15));
MV.insert(std::make_pair(6, 16));
ASSERT_EQ(MV.size(), 6u);
MV.remove_if([](const std::pair<int, int> &Val) { return Val.second % 2; });
ASSERT_EQ(MV.size(), 3u);
ASSERT_EQ(MV.find(1), MV.end());
ASSERT_EQ(MV.find(3), MV.end());
ASSERT_EQ(MV.find(5), MV.end());
ASSERT_EQ(MV[2], 12);
ASSERT_EQ(MV[4], 14);
ASSERT_EQ(MV[6], 16);
}