]> www.ginac.de Git - ginac.git/commitdiff
* Add virtual method remove_all() to the containers (by Roberto Bagnara).
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Mon, 5 Aug 2002 22:03:01 +0000 (22:03 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Mon, 5 Aug 2002 22:03:01 +0000 (22:03 +0000)
doc/tutorial/ginac.texi
ginac/container.pl

index 3c88ec309362479b78762aca1114a58bc19f2577..2e06d46b133a3ccecdcdeba12925ca686e5e7423 100644 (file)
@@ -1214,6 +1214,7 @@ canonical form.
 @cindex @code{prepend()}
 @cindex @code{remove_first()}
 @cindex @code{remove_last()}
+@cindex @code{remove_all()}
 
 The GiNaC class @code{lst} serves for holding a @dfn{list} of arbitrary
 expressions. These are sometimes used to supply a variable number of
@@ -1251,13 +1252,21 @@ and @code{prepend()} methods:
     // ...
 @end example
 
-Finally you can remove the first or last element of a list with
+You can remove the first or last element of a list with
 @code{remove_first()} and @code{remove_last()}:
 
 @example
     // ...
     l.remove_first();   // l is now @{x, 2, y, x+y, 4*x@}
     l.remove_last();    // l is now @{x, 2, y, x+y@}
+@end example
+
+Finally, you can remove all the elements of a list with
+@code{remove_all()}:
+
+@example
+    // ...
+    l.remove_all();   // l is now empty
 @}
 @end example
 
index d187d0654d6973076b9bacc2431d732678b73d53..2860ccf142048b3be3b3011a14e971a08427fb43 100755 (executable)
@@ -250,6 +250,7 @@ protected:
 public:
        virtual ${CONTAINER} & append(const ex & b);
        virtual ${CONTAINER} & remove_last(void);
+       virtual ${CONTAINER} & remove_all(void);
 ${PREPEND_INTERFACE}
 ${SORT_INTERFACE}
 protected:
@@ -547,6 +548,13 @@ ${CONTAINER} & ${CONTAINER}::remove_last(void)
        return *this;
 }
 
+${CONTAINER} & ${CONTAINER}::remove_all(void)
+{
+       ensure_if_modifiable();
+       seq.clear();
+       return *this;
+}
+
 ${PREPEND_IMPLEMENTATION}
 
 ${SORT_IMPLEMENTATION}