mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-29 13:32:33 +00:00
Add MapVector::rbegin(), MapVector::rend() to completment MapVector::begin(), MapVector::end().
These just delegate to the underlying vector type in the MapVector. Also just add in some sanity unittests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220687 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
af628cc0b8
commit
86ec9c4081
@ -37,26 +37,20 @@ class MapVector {
|
||||
public:
|
||||
typedef typename VectorType::iterator iterator;
|
||||
typedef typename VectorType::const_iterator const_iterator;
|
||||
typedef typename VectorType::reverse_iterator reverse_iterator;
|
||||
typedef typename VectorType::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
size_type size() const {
|
||||
return Vector.size();
|
||||
}
|
||||
size_type size() const { return Vector.size(); }
|
||||
|
||||
iterator begin() {
|
||||
return Vector.begin();
|
||||
}
|
||||
iterator begin() { return Vector.begin(); }
|
||||
const_iterator begin() const { return Vector.begin(); }
|
||||
iterator end() { return Vector.end(); }
|
||||
const_iterator end() const { return Vector.end(); }
|
||||
|
||||
const_iterator begin() const {
|
||||
return Vector.begin();
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return Vector.end();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return Vector.end();
|
||||
}
|
||||
reverse_iterator rbegin() { return Vector.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return Vector.rbegin(); }
|
||||
reverse_iterator rend() { return Vector.rend(); }
|
||||
const_reverse_iterator rend() const { return Vector.rend(); }
|
||||
|
||||
bool empty() const {
|
||||
return Vector.empty();
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include <utility>
|
||||
|
||||
using namespace llvm;
|
||||
@ -97,3 +98,27 @@ TEST(MapVectorTest, remove_if) {
|
||||
ASSERT_EQ(MV[4], 14);
|
||||
ASSERT_EQ(MV[6], 16);
|
||||
}
|
||||
|
||||
TEST(MapVectorTest, iteration_test) {
|
||||
MapVector<int, int> MV;
|
||||
|
||||
MV.insert(std::make_pair(1, 11));
|
||||
MV.insert(std::make_pair(2, 12));
|
||||
MV.insert(std::make_pair(3, 13));
|
||||
MV.insert(std::make_pair(4, 14));
|
||||
MV.insert(std::make_pair(5, 15));
|
||||
MV.insert(std::make_pair(6, 16));
|
||||
ASSERT_EQ(MV.size(), 6u);
|
||||
|
||||
int count = 1;
|
||||
for (auto P : make_range(MV.begin(), MV.end())) {
|
||||
ASSERT_EQ(P.first, count);
|
||||
count++;
|
||||
}
|
||||
|
||||
count = 6;
|
||||
for (auto P : make_range(MV.rbegin(), MV.rend())) {
|
||||
ASSERT_EQ(P.first, count);
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user