From 8568122b41340e9c3bfac47f3714db4241196fbd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 20 Aug 2007 21:22:48 +0000 Subject: [PATCH] add reverse iterators to smallvector git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41198 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/SmallVector.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index dfb761699f7..eb2ffb9d8a2 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -14,8 +14,8 @@ #ifndef LLVM_ADT_SMALLVECTOR_H #define LLVM_ADT_SMALLVECTOR_H +#include "llvm/ADT/iterator" #include -#include #include #ifdef _MSC_VER @@ -90,18 +90,29 @@ public: typedef size_t size_type; typedef T* iterator; typedef const T* const_iterator; + + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef T& reference; typedef const T& const_reference; bool empty() const { return Begin == End; } size_type size() const { return End-Begin; } - + + // forward iterator creation methods. iterator begin() { return Begin; } const_iterator begin() const { return Begin; } - iterator end() { return End; } const_iterator end() const { return End; } + // reverse iterator creation methods. + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin());} + + reference operator[](unsigned idx) { return Begin[idx]; }