mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +01:00
[ADT] Add initializer_list constructor to SmallDenseMap
Make it easier to initialize small maps inline. Note that DenseMap already has an initializer_list constructor. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D106363
This commit is contained in:
parent
94824eaca5
commit
fe1c7a103a
@ -924,6 +924,9 @@ public:
|
||||
this->insert(I, E);
|
||||
}
|
||||
|
||||
SmallDenseMap(std::initializer_list<typename BaseT::value_type> Vals)
|
||||
: SmallDenseMap(Vals.begin(), Vals.end()) {}
|
||||
|
||||
~SmallDenseMap() {
|
||||
this->destroyAll();
|
||||
deallocateBuckets();
|
||||
|
@ -547,6 +547,15 @@ TEST(DenseMapCustomTest, FindAsTest) {
|
||||
EXPECT_TRUE(map.find_as("d") == map.end());
|
||||
}
|
||||
|
||||
TEST(DenseMapCustomTest, SmallDenseMapInitializerList) {
|
||||
SmallDenseMap<int, int> M = {{0, 0}, {0, 1}, {1, 2}};
|
||||
EXPECT_EQ(2u, M.size());
|
||||
EXPECT_EQ(1u, M.count(0));
|
||||
EXPECT_EQ(0, M[0]);
|
||||
EXPECT_EQ(1u, M.count(1));
|
||||
EXPECT_EQ(2, M[1]);
|
||||
}
|
||||
|
||||
struct ContiguousDenseMapInfo {
|
||||
static inline unsigned getEmptyKey() { return ~0; }
|
||||
static inline unsigned getTombstoneKey() { return ~0U - 1; }
|
||||
|
Loading…
Reference in New Issue
Block a user