1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // iterator erase(const_iterator p)
17 #include "min_allocator.h"
21 make(int size, int start = 0 )
23 const int b = 4096 / sizeof(int);
27 init = (start+1) / b + ((start+1) % b != 0);
32 for (int i = 0; i < init-start; ++i)
34 for (int i = 0; i < size; ++i)
36 for (int i = 0; i < start; ++i)
45 typedef typename C::iterator I;
46 assert(P < c1.size());
47 std::size_t c1_osize = c1.size();
48 I i = c1.erase(c1.cbegin() + P);
49 assert(i == c1.begin() + P);
50 assert(c1.size() == c1_osize - 1);
51 assert(distance(c1.begin(), c1.end()) == c1.size());
54 for (; j < P; ++j, ++i)
56 for (++j; j < c1_osize; ++j, ++i)
62 testN(int start, int N)
64 int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
65 for (int p = 0; p < N; p += pstep)
67 C c1 = make<C>(N, start);
75 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
76 const int N = sizeof(rng)/sizeof(rng[0]);
77 for (int i = 0; i < N; ++i)
78 for (int j = 0; j < N; ++j)
79 testN<std::deque<int> >(rng[i], rng[j]);
81 #if __cplusplus >= 201103L
83 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
84 const int N = sizeof(rng)/sizeof(rng[0]);
85 for (int i = 0; i < N; ++i)
86 for (int j = 0; j < N; ++j)
87 testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);