From 5e8775425063e7067dde18e893977bb9cef0558e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 15 Jul 2004 08:18:31 +0000 Subject: [PATCH] Give SetVector range support git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14855 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/SetVector.h | 18 +++++++++++++++++- include/llvm/ADT/SetVector.h | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/include/Support/SetVector.h b/include/Support/SetVector.h index a6e3f850fd2..1b250ad670b 100644 --- a/include/Support/SetVector.h +++ b/include/Support/SetVector.h @@ -28,7 +28,6 @@ namespace llvm { /// @breif A vector that has set insertion semantics. template class SetVector { - public: typedef T value_type; typedef T key_type; @@ -40,6 +39,15 @@ public: typedef typename vector_type::const_iterator const_iterator; typedef typename vector_type::size_type size_type; + /// @brief Construct an empty SetVector + SetVector() {} + + /// @brief Initialize a SetVector with a range of elements + template + SetVector( It Start, It End ) { + insert(Start, End); + } + /// @brief Completely clear the SetVector void clear() { set_.clear(); @@ -91,6 +99,14 @@ public: return result; } + /// @brief Insert a range of elements into the SetVector. + template + void insert( It Start, It End ) { + for (; Start != End; ++Start) + if ( set_.insert(*Start).second ) + vector_.push_back(*Start); + } + /// @returns 0 if the element is not in the SetVector, 1 if it is. /// @brief Count the number of elements of a given key in the SetVector. size_type count( const key_type& key ) const { diff --git a/include/llvm/ADT/SetVector.h b/include/llvm/ADT/SetVector.h index a6e3f850fd2..1b250ad670b 100644 --- a/include/llvm/ADT/SetVector.h +++ b/include/llvm/ADT/SetVector.h @@ -28,7 +28,6 @@ namespace llvm { /// @breif A vector that has set insertion semantics. template class SetVector { - public: typedef T value_type; typedef T key_type; @@ -40,6 +39,15 @@ public: typedef typename vector_type::const_iterator const_iterator; typedef typename vector_type::size_type size_type; + /// @brief Construct an empty SetVector + SetVector() {} + + /// @brief Initialize a SetVector with a range of elements + template + SetVector( It Start, It End ) { + insert(Start, End); + } + /// @brief Completely clear the SetVector void clear() { set_.clear(); @@ -91,6 +99,14 @@ public: return result; } + /// @brief Insert a range of elements into the SetVector. + template + void insert( It Start, It End ) { + for (; Start != End; ++Start) + if ( set_.insert(*Start).second ) + vector_.push_back(*Start); + } + /// @returns 0 if the element is not in the SetVector, 1 if it is. /// @brief Count the number of elements of a given key in the SetVector. size_type count( const key_type& key ) const { -- 2.34.1