We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd2976e commit 91e8c32Copy full SHA for 91e8c32
SLLst.cpp
@@ -0,0 +1,33 @@
1
+#include "SLLst.h"
2
+#include <iostream>
3
+
4
+template <class T>
5
+SLLst<T>::~SLLst() {
6
+ for (SLLstNode * p;!isEmpty();) {
7
+ p=head->next;
8
+ delet head;
9
+ head=p;
10
+ }
11
+}
12
13
+SLLst<T>::addToHead(const T & el) {
14
+ head=new SLLstNode(el,head);
15
+ if(tail == 0)
16
+ tail=head;
17
18
19
+T SLLst<T>::deletFromTail() {
20
+ T el = tail->info;
21
+ if (head == tail) {
22
+ delete head;
23
+ head =tail =0 ;
24
25
+ else {
26
+ SLLstNode * tmp;
27
+ for (tmp = head;tmp->next != tail ; tmp=tmp->next) ;
28
+ delete tail;
29
+ tail =tmp;
30
+ tail->next = 0;
31
32
+ return el;
33
0 commit comments