Michigan State University
EECS 280
#ifndef LIST_H #define LIST_H /* List.h * * doubly-linked, double-ended list with Iterator interface * Project UID c1f28c309e55405daf00c565d57ff9ad * EECS 280 Project 4 */ #include #include //assert #include //NULL template class List { //OVERVIEW: a doubly-linked, double-ended list with Iterator interface public: List() : first(nullptr), last(nu
...[Show More]
#ifndef LIST_H #define LIST_H /* List.h * * doubly-linked, double-ended list with Iterator interface * Project UID c1f28c309e55405daf00c565d57ff9ad * EECS 280 Project 4 */ #include #include //assert #include //NULL template class List { //OVERVIEW: a doubly-linked, double-ended list with Iterator interface public: List() : first(nullptr), last(nullptr){} List(const List &other) : first(nullptr), last(nullptr) { copy_all(other); } ~List(){ clear(); } List & operator=(const List &rhs){ if (this == &rhs) {return *this;} clear(); copy_all(rhs); return *this; } //EFFECTS: returns true if the list is empty bool empty() const{ if(first == NULL){return true;} return false; } //EFFECTS: returns the number of elements in this List int size() const{ int size = 0; Node *ptr = first; while(ptr){ size++; ptr = ptr->next; } return size; } //REQUIRES: list is not empty //EFFECTS: Returns the first element in the list by reference T & front() { assert(!empty()); return first->
[Show Less]