std::string DoTestFrontBack(size_t n) { TCounter::Reset(); { constexpr int M = 10; TCounter data[M]; TList<TCounter, std::allocator<TCounter>> lst; for (size_t i = 0; i < n; ++i) { lst.push_back(TCounter(data[i % M])); } if (lst.size() != n) return "lst.size(): wrong answer"; if (lst.back().GetData() != data[(n + M - 1) % M].GetData()) return "lst.back(): wrong answer"; if (lst.front().GetData() != data[0].GetData()) return "lst.front(): wrong answer"; while (!lst.empty()) lst.pop_back(); for (size_t i = 0; i < n; ++i) { lst.push_front(TCounter(data[i % M])); } if (lst.size() != n) return "lst.size(): wrong answer"; if (lst.front().GetData() != data[(n + M - 1) % M].GetData()) return "lst.back(): wrong answer"; if (lst.back().GetData() != data[0].GetData()) return "lst.front(): wrong answer"; while (!lst.empty()) lst.pop_front(); } TCounter::CheckTotalOperationsCount(n * 10 + 100, n + 100); return TCounter::GetAllErrors(); }
void splice(TConstListIterator position, TList<T, Allocator> &list) { size_t counter = list.size(); for (; counter > 0; --counter) { insert(position, list.front()); list.pop_front(); } }