diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-02-19 11:17:16 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-02-19 11:17:16 +0100 |
commit | fc5512ffa6091544d8e310ab7b7876f05f73f2de (patch) | |
tree | c9a8248c38e265dee748515dcdc5f7d02be5c02f /linked_list.h | |
parent | Now it links, but segfaults. (diff) | |
download | calp-fc5512ffa6091544d8e310ab7b7876f05f73f2de.tar.gz calp-fc5512ffa6091544d8e310ab7b7876f05f73f2de.tar.xz |
Jag kan inte ens programmera på rätt dator...
Diffstat (limited to 'linked_list.h')
-rw-r--r-- | linked_list.h | 15 |
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>); |