Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions chapter_3/linked_list/GenericLinkedList/SLinkedList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ SLinkedList<E>::~SLinkedList() {


template <class E>
bool SLinkedList::empty() const {
bool SLinkedList<E>::empty() const {
return head == NULL;
}


template <class E>
const E& SLinkedList::front() const {
const E& SLinkedList<E>::front() const {
return head -> ele;
}

template <class E>
void SLinkedList::addFront(const E& e) {
SNode*<E> v = new SNode;
void SLinkedList<E>::addFront(const E& e) {
SNode<E>* v = new SNode<E>;
v -> ele = e;
v -> next = head;
head = v;
}


template <class E>
void removeFront() {
SNode*<E> old = head;
void SLinkedList<E>::removeFront() {
SNode<E>* old = head;
head = head -> next;
delete old;
}

template <class E>
void printList() {
SNode<E>* temp = new SNode;
void SLinkedList<E>::printList() {
SNode<E>* temp = new SNode<E>;
temp = head;
while(temp != NULL) {
cout << temp -> ele << "\n";
Expand Down
4 changes: 2 additions & 2 deletions chapter_3/linked_list/GenericLinkedList/SLinkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class SLinkedList {
SLinkedList();
~SLinkedList();
bool empty() const;
const <E>& front() const;
void addFront(const <E>& e);
const E& front() const;
void addFront(const E& e);
void removeFront();
void printList();
};
Expand Down