diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-02-19 12:08:03 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-02-19 12:08:03 +0100 |
commit | 86cb382c91fa965ad84d97c8c8e21957e695a1ae (patch) | |
tree | 88b5fc4e4eac2554a31485342d2d1c8bc5255075 /linked_list.cpp | |
parent | Jag kan inte ens programmera på rätt dator... (diff) | |
download | calp-86cb382c91fa965ad84d97c8c8e21957e695a1ae.tar.gz calp-86cb382c91fa965ad84d97c8c8e21957e695a1ae.tar.xz |
Further changes.
Diffstat (limited to 'linked_list.cpp')
-rw-r--r-- | linked_list.cpp | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/linked_list.cpp b/linked_list.cpp deleted file mode 100644 index ed37eb23..00000000 --- a/linked_list.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "linked_list.h" - -template <typename T> -llink<T>::~llink () { - this.unlink(); -} - -template <typename T> -void llink<T>::unlink () { - if (this->before != nullptr) this->before->after = this->after; - if (this->after != nullptr) this->after->before = this->before; -} - -template <typename T> -T& llist<T>::peek() { - if (this->empty()) return nullptr; - - return FIRST(this)->value; -} - -template <typename T> -T& llist<T>::pop() { - if (this->empty()) return nullptr; - - llink<T>* frst = FIRST(this); - frst.unlinke(); - - T& retval = frst->value; - --this->length; - delete frst; - - return retval; -} - -template <typename T> -void llist<T>::operator+= (llist<T>& other) { - - /* Link end of dest onto start of new__. */ - LAST(this)->after = FIRST(other); - FIRST(other)->before = LAST(this); - - /* Free the two now not needed end links. */ - delete other->head; - delete other->tail; - - /* Update dest with new__ tail ptr. */ - this->tail = other->tail; - - this->length += other->length; -} - -// template <typename T> -// std::ostream& std::operator<<(std::ostream&, llist<T>) { -// o << '('; -// for (T t : list) { -// o << t; -// } -// o << ')'; -// } |