cis22c/04-dl-lists/ListNodeADT.h

48 lines
1.2 KiB
C++

// Specification file for the ListNode class
// Written by: Iurii Tatishchev
// Reviewed & Modified by: Iurii Tatishchev
// IDE: CLion
#ifndef LISTNODE_H
#define LISTNODE_H
#include <iostream>
// #include "Park.h"
// ^^^ not included here anymore
template<class T>
class ListNode {
private:
T data; // store data
ListNode *forw; // a pointer to the next node in the list
ListNode *back; // a pointer to the previous node in the list
public:
//Constructor
ListNode() { forw = back = nullptr; }
ListNode(const T &dataIn, ListNode *forw = nullptr, ListNode *back = nullptr) {
data = dataIn;
this->forw = forw;
this->back = back;
}
// setters
// set the data
void setData(const T &dataIn) { data = dataIn; }
// set the forw pointer
void setNext(ListNode *nextPtr) { forw = nextPtr; }
// set the back pointer
void setPrev(ListNode *prevPtr) { back = prevPtr; }
// getters
// return data object in the listnode
T& getData() { return data; }
// return pointer in the next node
ListNode *getNext() const { return forw; }
// return pointer in the previous node
ListNode *getPrev() const { return back; }
};
#endif