本文整理汇总了C++中std::map::crbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ map::crbegin方法的具体用法?C++ map::crbegin怎么用?C++ map::crbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::map
的用法示例。
在下文中一共展示了map::crbegin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::vector<std::vector<size_t> > InstructionScheduler::genDimOrders(const std::map<bh_intp, bh_int64>& sweeps,
const size_t ndim)
{
/* First generate "basic" dimension orders:
* [0]
* [0,1]
* [0,1,2] -> [z,y,x]
* ...
*/
std::vector<std::vector<size_t> > dimOrders;
for (size_t d = 0; d < ndim; ++d)
{
dimOrders.push_back(std::vector<size_t>());
for (size_t i = 0; i < d+1; ++i)
{
dimOrders[d].push_back(i);
}
}
/* Rearrange the orders according to sweeps by moving the indicated
* dimension first in the given dimensionality and doing the same for
* esponding dimensions in higher dimensionality - skipping the highest
* (first) dimensions.
*/
for (auto rit = sweeps.crbegin(); rit != sweeps.crend(); ++rit)
{
bh_int64 s = rit->second;
bh_int64 o = 0;
for (bh_intp d = rit->first - 1; d < (int)ndim; ++d)
{
size_t t = dimOrders[d][s+o];
for (bh_int64 i = s; i > 0; --i)
{
dimOrders[d][i+o] = dimOrders[d][i+o-1];
}
dimOrders[d][o++] = t;
}
}
// std::cout << "dimOrders: {";
// for (const std::vector<size_t>& dimOrder: dimOrders)
// {
// std::cout << " [" << dimOrder[0];
// for (int i = 1; i < (int)dimOrder.size();++i)
// std::cout << ", " << dimOrder[i];
// std::cout << "] ";
// }
// std::cout << "}" << std::endl;
return dimOrders;
}
示例2: main
int main()
{
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
assert(std::distance(m.begin(), m.end()) == m.size());
assert(std::distance(m.rbegin(), m.rend()) == m.size());
std::map<int, double>::iterator i;
i = m.begin();
std::map<int, double>::const_iterator k = i;
assert(i == k);
for (int j = 1; j <= m.size(); ++j, ++i)
{
assert(i->first == j);
assert(i->second == 1);
i->second = 2.5;
assert(i->second == 2.5);
}
}
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
assert(std::distance(m.begin(), m.end()) == m.size());
assert(std::distance(m.cbegin(), m.cend()) == m.size());
assert(std::distance(m.rbegin(), m.rend()) == m.size());
assert(std::distance(m.crbegin(), m.crend()) == m.size());
std::map<int, double>::const_iterator i;
i = m.begin();
for (int j = 1; j <= m.size(); ++j, ++i)
{
assert(i->first == j);
assert(i->second == 1);
}
}
#if __cplusplus >= 201103L
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
//.........这里部分代码省略.........
示例3: main
int main()
{
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
assert(std::distance(m.begin(), m.end()) == m.size());
assert(std::distance(m.rbegin(), m.rend()) == m.size());
std::map<int, double>::iterator i;
i = m.begin();
std::map<int, double>::const_iterator k = i;
assert(i == k);
for (int j = 1; j <= m.size(); ++j, ++i)
{
assert(i->first == j);
assert(i->second == 1);
i->second = 2.5;
assert(i->second == 2.5);
}
}
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
assert(std::distance(m.begin(), m.end()) == m.size());
assert(std::distance(m.cbegin(), m.cend()) == m.size());
assert(std::distance(m.rbegin(), m.rend()) == m.size());
assert(std::distance(m.crbegin(), m.crend()) == m.size());
std::map<int, double>::const_iterator i;
i = m.begin();
for (int j = 1; j <= m.size(); ++j, ++i)
{
assert(i->first == j);
assert(i->second == 1);
}
}
#if __cplusplus >= 201103L || defined(_LIBCPP_MSVC)
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
//.........这里部分代码省略.........
示例4: tc_libcxx_containers_map_access_iterator
int tc_libcxx_containers_map_access_iterator(void)
{
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
std::map<int, double>::iterator i;
i = m.begin();
std::map<int, double>::const_iterator k = i;
TC_ASSERT_EXPR(i == k);
for (int j = 1; static_cast<std::size_t>(j) <= m.size(); ++j, ++i)
{
TC_ASSERT_EXPR(i->first == j);
TC_ASSERT_EXPR(i->second == 1);
i->second = 2.5;
TC_ASSERT_EXPR(i->second == 2.5);
}
}
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(m.cbegin(), m.cend())) == m.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(m.crbegin(), m.crend())) == m.size());
std::map<int, double>::const_iterator i;
i = m.begin();
for (int j = 1; static_cast<std::size_t>(j) <= m.size(); ++j, ++i)
{
TC_ASSERT_EXPR(i->first == j);
TC_ASSERT_EXPR(i->second == 1);
}
}
#if TEST_STD_VER > 11
{ // N3644 testing
typedef std::map<int, double> C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
TC_ASSERT_EXPR ( ii1 == ii2 );
TC_ASSERT_EXPR ( ii1 == ii4 );
TC_ASSERT_EXPR (!(ii1 != ii2 ));
TC_ASSERT_EXPR ( (ii1 == cii ));
//.........这里部分代码省略.........
示例5: crbegin
ConstReverseTextureIterator crbegin() const
{
return textures.crbegin();
}