Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// void clear();
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
m.clear();
|
||||
assert(m.size() == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
m.clear();
|
||||
assert(m.size() == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,150 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace(Args&&... args);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "DefaultOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef std::multimap<int, DefaultOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace();
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 3);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multimap<int, Emplaceable> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
|
||||
std::forward_as_tuple());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(3, 3.5));
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == Emplaceable(3, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace(M::value_type(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace();
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 3);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
|
||||
std::forward_as_tuple());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(3, 3.5));
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == Emplaceable(3, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace(M::value_type(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,160 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "DefaultOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef std::multimap<int, DefaultOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace_hint(m.cend());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace_hint(m.cend(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace_hint(m.cend(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 3);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multimap<int, Emplaceable> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend(), std::piecewise_construct,
|
||||
std::forward_as_tuple(2),
|
||||
std::forward_as_tuple());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(3, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == Emplaceable(3, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace_hint(m.cend());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace_hint(m.cend(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace_hint(m.cend(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple());
|
||||
assert(r == next(m.begin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 3);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend(), std::piecewise_construct,
|
||||
std::forward_as_tuple(2),
|
||||
std::forward_as_tuple());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
|
||||
std::forward_as_tuple(1),
|
||||
std::forward_as_tuple(3, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == Emplaceable(3, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,279 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator erase(const_iterator position);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
I i = m.erase(next(m.cbegin(), 3));
|
||||
assert(m.size() == 8);
|
||||
assert(i == next(m.begin(), 3));
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 1.5);
|
||||
assert(next(m.begin(), 4)->first == 2);
|
||||
assert(next(m.begin(), 4)->second == 2);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 1);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 1.5);
|
||||
assert(next(m.begin(), 7)->first == 3);
|
||||
assert(next(m.begin(), 7)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 7);
|
||||
assert(i == m.begin());
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 1.5);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 1.5);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 5));
|
||||
assert(m.size() == 6);
|
||||
assert(i == prev(m.end()));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 1.5);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 5);
|
||||
assert(i == next(m.begin()));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 4);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 1);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 0));
|
||||
assert(next(m.begin(), 0)->first == 2);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 3);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 1);
|
||||
assert(i == m.end());
|
||||
assert(next(m.begin(), 0)->first == 2);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
|
||||
i = m.erase(m.cbegin());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
I i = m.erase(next(m.cbegin(), 3));
|
||||
assert(m.size() == 8);
|
||||
assert(i == next(m.begin(), 3));
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 1.5);
|
||||
assert(next(m.begin(), 4)->first == 2);
|
||||
assert(next(m.begin(), 4)->second == 2);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 1);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 1.5);
|
||||
assert(next(m.begin(), 7)->first == 3);
|
||||
assert(next(m.begin(), 7)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 7);
|
||||
assert(i == m.begin());
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 1.5);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 1.5);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 5));
|
||||
assert(m.size() == 6);
|
||||
assert(i == prev(m.end()));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 1.5);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 5);
|
||||
assert(i == next(m.begin()));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 4);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 1);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 0));
|
||||
assert(next(m.begin(), 0)->first == 2);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 3);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 1);
|
||||
assert(i == m.end());
|
||||
assert(next(m.begin(), 0)->first == 2);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
|
||||
i = m.erase(m.cbegin());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,157 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
I i = m.erase(m.cbegin(), m.cbegin());
|
||||
assert(m.size() == 8);
|
||||
assert(i == m.begin());
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1.5);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 2.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 3.5);
|
||||
assert(next(m.begin(), 3)->first == 4);
|
||||
assert(next(m.begin(), 3)->second == 4.5);
|
||||
assert(next(m.begin(), 4)->first == 5);
|
||||
assert(next(m.begin(), 4)->second == 5.5);
|
||||
assert(next(m.begin(), 5)->first == 6);
|
||||
assert(next(m.begin(), 5)->second == 6.5);
|
||||
assert(next(m.begin(), 6)->first == 7);
|
||||
assert(next(m.begin(), 6)->second == 7.5);
|
||||
assert(next(m.begin(), 7)->first == 8);
|
||||
assert(next(m.begin(), 7)->second == 8.5);
|
||||
|
||||
i = m.erase(m.cbegin(), next(m.cbegin(), 2));
|
||||
assert(m.size() == 6);
|
||||
assert(i == m.begin());
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
assert(next(m.begin(), 5)->first == 8);
|
||||
assert(next(m.begin(), 5)->second == 8.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
|
||||
i = m.erase(m.cbegin(), m.cend());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
I i = m.erase(m.cbegin(), m.cbegin());
|
||||
assert(m.size() == 8);
|
||||
assert(i == m.begin());
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1.5);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 2.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 3.5);
|
||||
assert(next(m.begin(), 3)->first == 4);
|
||||
assert(next(m.begin(), 3)->second == 4.5);
|
||||
assert(next(m.begin(), 4)->first == 5);
|
||||
assert(next(m.begin(), 4)->second == 5.5);
|
||||
assert(next(m.begin(), 5)->first == 6);
|
||||
assert(next(m.begin(), 5)->second == 6.5);
|
||||
assert(next(m.begin(), 6)->first == 7);
|
||||
assert(next(m.begin(), 6)->second == 7.5);
|
||||
assert(next(m.begin(), 7)->first == 8);
|
||||
assert(next(m.begin(), 7)->second == 8.5);
|
||||
|
||||
i = m.erase(m.cbegin(), next(m.cbegin(), 2));
|
||||
assert(m.size() == 6);
|
||||
assert(i == m.begin());
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
assert(next(m.begin(), 5)->first == 8);
|
||||
assert(next(m.begin(), 5)->second == 8.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
|
||||
i = m.erase(m.cbegin(), m.cend());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,153 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// size_type erase(const key_type& k);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::size_type I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
I i = m.erase(2);
|
||||
assert(m.size() == 6);
|
||||
assert(i == 3);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(2);
|
||||
assert(m.size() == 6);
|
||||
assert(i == 0);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(3);
|
||||
assert(i == 3);
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
|
||||
i = m.erase(1);
|
||||
assert(m.size() == 0);
|
||||
assert(i == 3);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::size_type I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
I i = m.erase(2);
|
||||
assert(m.size() == 6);
|
||||
assert(i == 3);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(2);
|
||||
assert(m.size() == 6);
|
||||
assert(i == 0);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(3);
|
||||
assert(i == 3);
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
|
||||
i = m.erase(1);
|
||||
assert(m.size() == 0);
|
||||
assert(i == 3);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator insert(const value_type& v);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2.5);
|
||||
|
||||
r = m.insert(M::value_type(1, 1.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2.5);
|
||||
|
||||
r = m.insert(M::value_type(1, 1.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// void insert(initializer_list<value_type> il);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
typedef std::multimap<int, double> C;
|
||||
typedef C::value_type V;
|
||||
C m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 2}
|
||||
};
|
||||
m.insert(
|
||||
{
|
||||
{1, 1.5},
|
||||
{2, 1.5},
|
||||
{3, 1.5},
|
||||
}
|
||||
);
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
C::const_iterator i = m.cbegin();
|
||||
assert(*i == V(1, 1));
|
||||
assert(*++i == V(1, 2));
|
||||
assert(*++i == V(1, 1.5));
|
||||
assert(*++i == V(2, 1));
|
||||
assert(*++i == V(2, 2));
|
||||
assert(*++i == V(2, 1.5));
|
||||
assert(*++i == V(3, 1));
|
||||
assert(*++i == V(3, 2));
|
||||
assert(*++i == V(3, 1.5));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
|
||||
typedef C::value_type V;
|
||||
C m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 2}
|
||||
};
|
||||
m.insert(
|
||||
{
|
||||
{1, 1.5},
|
||||
{2, 1.5},
|
||||
{3, 1.5},
|
||||
}
|
||||
);
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
C::const_iterator i = m.cbegin();
|
||||
assert(*i == V(1, 1));
|
||||
assert(*++i == V(1, 2));
|
||||
assert(*++i == V(1, 1.5));
|
||||
assert(*++i == V(2, 1));
|
||||
assert(*++i == V(2, 2));
|
||||
assert(*++i == V(2, 1.5));
|
||||
assert(*++i == V(3, 1));
|
||||
assert(*++i == V(3, 2));
|
||||
assert(*++i == V(3, 1.5));
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator insert(const_iterator position, const value_type& v);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.end(), M::value_type(2, 2.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(1, 1.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
|
||||
r = m.insert(prev(m.end()), M::value_type(3, 4.5));
|
||||
assert(r == prev(m.end(), 2));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 4.5);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.end(), M::value_type(2, 2.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(1, 1.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
|
||||
r = m.insert(prev(m.end()), M::value_type(3, 4.5));
|
||||
assert(r == prev(m.end(), 2));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 4.5);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class InputIterator>
|
||||
// void insert(InputIterator first, InputIterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m;
|
||||
m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
|
||||
assert(m.size() == 9);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 2);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 2);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 1);
|
||||
assert(next(m.begin(), 7)->first == 3);
|
||||
assert(next(m.begin(), 7)->second == 1.5);
|
||||
assert(next(m.begin(), 8)->first == 3);
|
||||
assert(next(m.begin(), 8)->second == 2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m;
|
||||
m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
|
||||
assert(m.size() == 9);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 2);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 2);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 1);
|
||||
assert(next(m.begin(), 7)->first == 3);
|
||||
assert(next(m.begin(), 7)->second == 1.5);
|
||||
assert(next(m.begin(), 8)->first == 3);
|
||||
assert(next(m.begin(), 8)->second == 2);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class P>
|
||||
// iterator insert(const_iterator position, P&& p);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef std::multimap<int, MoveOnly> M;
|
||||
typedef std::pair<int, MoveOnly> P;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.cend(), P(2, 2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2);
|
||||
|
||||
r = m.insert(m.cend(), P(1, 1));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1);
|
||||
|
||||
r = m.insert(m.cend(), P(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
|
||||
r = m.insert(m.cend(), P(3, 2));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
|
||||
typedef std::pair<int, MoveOnly> P;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.cend(), P(2, 2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2);
|
||||
|
||||
r = m.insert(m.cend(), P(1, 1));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1);
|
||||
|
||||
r = m.insert(m.cend(), P(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
|
||||
r = m.insert(m.cend(), P(3, 2));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 2);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class P>
|
||||
// iterator insert(P&& p);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef std::multimap<int, MoveOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2);
|
||||
|
||||
r = m.insert(M::value_type(1, 1));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2);
|
||||
|
||||
r = m.insert(M::value_type(1, 1));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
Reference in New Issue
Block a user