[llvm-commits] CVS: llvm/include/Support/SetVector.h

Chris Lattner lattner at cs.uiuc.edu
Thu Jul 15 01:18:44 PDT 2004



Changes in directory llvm/include/Support:

SetVector.h updated: 1.2 -> 1.3

---
Log message:

Give SetVector range support



---
Diffs of the changes:  (+17 -1)

Index: llvm/include/Support/SetVector.h
diff -u llvm/include/Support/SetVector.h:1.2 llvm/include/Support/SetVector.h:1.3
--- llvm/include/Support/SetVector.h:1.2	Thu Jul  8 16:50:33 2004
+++ llvm/include/Support/SetVector.h	Thu Jul 15 03:18:31 2004
@@ -28,7 +28,6 @@
 /// @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 @@
   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 @@
     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 {





More information about the llvm-commits mailing list