diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-15 08:18:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-15 08:18:31 +0000 |
commit | 5e8775425063e7067dde18e893977bb9cef0558e (patch) | |
tree | ff68c5e07c6f1dce34bd35e7015d61a7f929bd60 /include/Support/SetVector.h | |
parent | 69e5845a81c792c00e0a3f3017c3d464c40f3ba7 (diff) |
Give SetVector range support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/Support/SetVector.h')
-rw-r--r-- | include/Support/SetVector.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/Support/SetVector.h b/include/Support/SetVector.h index a6e3f850fd..1b250ad670 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 <typename T> 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<typename It> + 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<typename It> + 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 { |