aboutsummaryrefslogtreecommitdiff
path: root/linked_list.h
diff options
context:
space:
mode:
Diffstat (limited to 'linked_list.h')
-rw-r--r--linked_list.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/linked_list.h b/linked_list.h
index 7ed4c6c4..75096a93 100644
--- a/linked_list.h
+++ b/linked_list.h
@@ -39,6 +39,8 @@ struct llist {
int size () { return length; }
bool empty () { return length == 0; }
+
+ void reset ();
};
template <typename T>
@@ -72,6 +74,19 @@ void llist<T>::push(T* val) {
this->__cur = l;
}
+template <typename T>
+void llist<T>::reset () {
+ llink<T> *link = this->first, *next;
+
+ while (link != this->tail) {
+ next = link->after;
+ delete link;
+ link = next;
+ }
+
+ this->__cur = this->head;
+}
+
// template <typename T>
// std::ostream& std::operator<<(std::ostream&, llist<T>);