add a new assign method
authorChris Lattner <sabre@nondot.org>
Tue, 8 Aug 2006 01:44:16 +0000 (01:44 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 8 Aug 2006 01:44:16 +0000 (01:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29562 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SmallVector.h

index a1d226be07ed63d4a91f7a0dd6842f5be580feae..0ade4847b43c0ba219a30533d19343b1835e8f61 100644 (file)
@@ -146,6 +146,15 @@ public:
     End += NumInputs;
   }
   
+  void assign(unsigned NumElts, const T &Elt) {
+    clear();
+    if (NumElts > Capacity)
+      grow(NumElts);
+    End = Begin+NumElts;
+    for (; NumElts; --NumElts)
+      new (Begin+NumElts-1) T(Elt);
+  }
+  
   const SmallVector &operator=(const SmallVector &RHS) {
     // Avoid self-assignment.
     if (this == &RHS) return *this;