From: Andy Street Date: Wed, 16 Jan 2019 21:11:23 +0000 (+0000) Subject: Add function to empty a TypedDoublyLinkedList X-Git-Url: https://git.street.me.uk/andy/gpx.git/commitdiff_plain/4b7a6b55583b3ac029d0f7a0b6aa58d0fd21684d Add function to empty a TypedDoublyLinkedList --- diff --git a/src/libgpx/typeddoublylinkedlist.php b/src/libgpx/typeddoublylinkedlist.php index b01ba0b..0c00e08 100644 --- a/src/libgpx/typeddoublylinkedlist.php +++ b/src/libgpx/typeddoublylinkedlist.php @@ -164,4 +164,16 @@ class TypedDoublyLinkedList extends SplDoublyLinkedList return parent::unshift($value); } + /** + * Empty the list. + * + * @return void + */ + public function empty() + { + while (!$this->isEmpty()) { + $this->pop(); + } + } + }