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; }
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), 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, std::less<int>, min_allocator<V>> 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, std::less<int>, min_allocator<V>>::iterator i; i = m.begin(); std::map<int, double, std::less<int>, min_allocator<V>>::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, std::less<int>, min_allocator<V>> 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, std::less<int>, min_allocator<V>>::const_iterator i; i = m.begin(); for (int j = 1; j <= m.size(); ++j, ++i) { assert(i->first == j); assert(i->second == 1); } } #endif }
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), 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, std::less<int>, min_allocator<V>> 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, std::less<int>, min_allocator<V>>::iterator i; i = m.begin(); std::map<int, double, std::less<int>, min_allocator<V>>::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, std::less<int>, min_allocator<V>> 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, std::less<int>, min_allocator<V>>::const_iterator i; i = m.begin(); for (int j = 1; j <= m.size(); ++j, ++i) { assert(i->first == j); assert(i->second == 1); } } #endif #if _LIBCPP_STD_VER > 11 { // N3644 testing typedef std::map<int, double> C; C::iterator ii1{}, ii2{}; C::iterator ii4 = ii1; C::const_iterator cii{}; assert ( ii1 == ii2 ); assert ( ii1 == ii4 ); assert (!(ii1 != ii2 )); assert ( (ii1 == cii )); assert ( (cii == ii1 )); assert (!(ii1 != cii )); assert (!(cii != ii1 )); } #endif }
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 )); TC_ASSERT_EXPR ( (cii == ii1 )); TC_ASSERT_EXPR (!(ii1 != cii )); TC_ASSERT_EXPR (!(cii != ii1 )); } #endif TC_SUCCESS_RESULT(); return 0; }
ConstReverseTextureIterator crbegin() const { return textures.crbegin(); }