in c++
The Node class must be represented as a template.
The Node class will require these private fields.
- T data: The data to hold in the Node
- Node* next: A pointer to the next Node (if any) in the chain of Nodes.
- Node* prev: A pointer to the previous Node (if any) in the chain of Nodes.
Linked List
This class will require the following fields:
- Node* mHead: Points the first Node in the chain
- Node* mTail: Points the last Node in the chain
- int mSize: Keeps a count of the number of Nodes in the chain
Your LinkedList class must also support the following public member functions.
- LinkedList(): A default constructor sets both pointers to null and sets the size to 0.
- LinkedList(const LinkedList&): A copy constructor that takes a LinkedList object and performs a deep copy of the passed list into this list.
- ~LinkedList(): A destructor that performs pop_front on the list while the list is not empty.
- operator=(const LinkedList&): LinkedList& An overloaded assignment operator that deletes the current array and replaces it with deep copy of the passed list.
- size() const: int: Returns the size of the LinkedList.
- push_back(const T): void: Creates a new Node and assigns it to the end of the list of Nodes while updating the size by 1.
- push_front(const T): void: Creates a new Node and assigns it to the front of the list of Nodes while updating the size by 1.
- pop_back(): T: Deletes the Node at the end of the list (or throws an error if this is not possible). Decreases size by 1. Returns the deleted element.
- pop_front(): T: Deletes the Node at the front of the list (or throws an error if this is not possible). Decreases size by 1. Returns the deleted element.
- at(int) const: T: Returns the element stored at the specified index. If the index is out-of-bounds (either for being negative or greater than/equal the size of the list), throw invalid\_argument("Index out of bounds.");. This will require you to include the stdexcept library. This method should operate at O(1) for accessing the first or last element in a list and at O(n) for any element other than the first or the last.
- front() const: T: Returns the first element.
- back() const: T: Returns the last element.
Return to the Books object.
Return to your Books code. Find Books.h and remove the import statements to vector.hpp and replace those with the local version of LinkedList.hpp that you made.
- Add a menu option to add to the beginning of the list.
- Add a menu option to remove the first Book in the list.
- Add a menu option to remove the last Book in the list.
- Add a menu option to remove every Book in the list.
Test your linked list application. Add a Book to the list 1,000 times. Add a second Book to the list 1,000 times. Remove the first Book in the list. Remove the last Book in the list. Verify that you have 1,998 Books in the list.
After you verify that there are 1,998 Books in the list, clear the list using your newest menu option. Verify that you have 0 Books in the list.
What to Hand In
Upload a zip file containing the following files to the drop box on D2L:
- LinkedList.hpp - the header file containing the entire class declaration and external definitions of the LinkedList class. Normally, the definitions would be in a separate file, but class templates need to be handled differently in order for them to be compiled properly by the C++ compiler.
- Node.hpp
- All files updated from the last homework assignment that have been updated to fit this new linked list.
- Make sure your name, CSCI 3250, and Programming Assignment 4 appear in comments in all of your files.
- Note: NO CREDIT will be given to programming assignments that do not compile.
- Make sure you have compiled and tested your program before handing it in.
8:23 RON Linked Ust N ebede in the Namo Nathan themes A lth the UNA Thawa ht www.sandstedt w as the fresh edhe pastropp M o ndd to the beginning the But yurity that we were in the w a r cutting the following to the drop hos DGE READ ONLY - This is an older file for... v The de class will require these private Tata: The catata held in the Nack NodeT>next poster to the next Noder any in the chain of Nodes Nadetspror: pointer to the previous Nodefny) in the chemin af Nacke Linked List This dass will require the following fields Notes med Paints the firstNode in the chain Node in Tail: points the last Node in the chain . it makes a count of the number of Nodes in the chain Your Linkedlist dass must also support the following public member functions. Linked ): A default coretructor set bota pentru truall and at the total Unredlist coast Lisked copy constructor ho takes a s u ist obiect and partea dep copy of the passed list in the list. -Linked ListAdestruktor that performis pop front on the list while the listing per recensuinkedI nked An overloaded assignment cecratchar deletes the current array and replace it with demey of the passed list back. The valt Create a www Nodanddris it to the end of the lite push frustcart T): vaid: Create an Node and it to the front of the staf Nodes while dating the sta by 1 pop back : Deletes the Node at the end of the list for throwanemurithis is not possibile. Decrease by 1. Returns the idete komen pop front. Deletes the Nade at the front of the list or throws an error if this is not p . De by 1. turns the dat e n antoons: T. Returns the element stored at the specified indes. If the index is out of-bounde (ether for being negativ e than equal the sto of the list, throw Invalid argument"Index out of bounds.");. This will require you to include the stdescept library. This method should operate at (1) for accessing the first or Last frant) const Returns the first element bakoit:: Return the last c ent Return to the Books object. Return to your Boole code. Find Books and remove the import statements to votar.hep cethewithe local sindiketListhp" that you made. A uution dd to things Adida me option to remove the first ook in the list Adida t ion to remove the b ook in the list Add a menu option to remate every look in the list 8:45 # READ ONLY - This is an older file for... Implement a linked list. Instructions Our last program was to maintain a list of books using a vector class crea assignment, you will be writing the linked list. Implement class Linkedli Nodes of a generic type. Nodes The Node class must be represented as a template. The Node class will require these private fields. Tdata: The data to hold in the Node Node
next: A pointer to the next Node (if any) in the chain of No Node* prev: A pointer to the previous Node (if any) in the chain Linked List This class will require the following fields: Node* mHead: Points the first Node in the chain Node T m Tail: Points the last Node in the chain . int mSize: Keeps a count of the number of Nodes in the chain Your LinkedList class must also support the following public member fu LinkedList(): A default constructor sets both pointers to null and set Linkedlist const LinkedList&): A copy constructor that takes a Link performs a deep copy of the passed list into this list. . --Linked List): A destructor that performs pop front on the list while empty. operator=(const LinkedList&): LinkedList& An averloaded assignme deletes the current array and replaces it with deep copy of the passe sized const: int: Returns the size of the Linkedlist. push_back(const T): void: Creates a new Node and assigns it to the e Nodes while updating the size by 1. push front const T): void: Creates a new Node and assigns it to the fo Nodes while updating the size by 1. pop back(): T: Deletes the Node at the end of the list for throws an e possible. Decreases size by 1. Returns the deleted element. 8:46 READ ONLY - This is an older file for... TAIP VEILE. 1.UCICUS VICIUC OLVIC I I U possible). Decreases size by 1. Returns the deleted element. at(int) const: T: Returns the element stored at the specified index of-bounds (either for being negative or greater than/equal the size invalid _argument("Index out of bounds."); This will requin stdexcept library. This method should operate at O(1) for accessi element in a list and at O(n) for any element other than the first or front const: T: Returns the first element. hack const: T. Returns the last element. Return to the Books object. Return to your Books code. Find Books and remove the import staten and replace those with the local version of 'Linkedlist.hpp" that you m Add a menu option to add to the beginning of the list. Add a menu option to remove the first Book in the list Add a menu option to remove the last Book in the list Add a menu option to remove every Book in the list. Test your linked list application. Add a Book to the list 1,000 times. Add the list 1,000 times. Remove the first Book in the list. Remove the last B Verify that you have 1,998 Books in the list. After you verify that there are 1,998 Books in the list, clear the list using option. Verify that you have 0 Books in the list. What to Hand In Upload a zip file containing the following files to the drop box on D2L: LinkedList.hpp - the header file containing the entire class declar delinitions of the Linkedlist class. Normally, the definitions woul file, but class templates need to be handled differently in order for compiled properly by the C++ compiler. Node.hpp All files updated from the last homework assignment that have bee new linked list. Make sure your name, CSCI 3250, and Programming Assignment 4 comments in all of your files, Note: NO CREDIT will be given to programming assignments that Make sure you have compiled and tested your program before han . . 8:23 RON Linked Ust N ebede in the Namo Nathan themes A lth the UNA Thawa ht www.sandstedt w as the fresh edhe pastropp M o ndd to the beginning the But yurity that we were in the w a r cutting the following to the drop hos DGE READ ONLY - This is an older file for... v The de class will require these private Tata: The catata held in the Nack NodeT>next poster to the next Noder any in the chain of Nodes Nadetspror: pointer to the previous Nodefny) in the chemin af Nacke Linked List This dass will require the following fields Notes med Paints the firstNode in the chain Node in Tail: points the last Node in the chain . it makes a count of the number of Nodes in the chain Your Linkedlist dass must also support the following public member functions. Linked ): A default coretructor set bota pentru truall and at the total Unredlist coast Lisked copy constructor ho takes a s u ist obiect and partea dep copy of the passed list in the list. -Linked ListAdestruktor that performis pop front on the list while the listing per recensuinkedI nked An overloaded assignment cecratchar deletes the current array and replace it with demey of the passed list back. The valt Create a www Nodanddris it to the end of the lite push frustcart T): vaid: Create an Node and it to the front of the staf Nodes while dating the sta by 1 pop back : Deletes the Node at the end of the list for throwanemurithis is not possibile. Decrease by 1. Returns the idete komen pop front. Deletes the Nade at the front of the list or throws an error if this is not p . De by 1. turns the dat e n antoons: T. Returns the element stored at the specified indes. If the index is out of-bounde (ether for being negativ e than equal the sto of the list, throw Invalid argument"Index out of bounds.");. This will require you to include the stdescept library. This method should operate at (1) for accessing the first or Last frant) const Returns the first element bakoit:: Return the last c ent Return to the Books object. Return to your Boole code. Find Books and remove the import statements to votar.hep cethewithe local sindiketListhp" that you made. A uution dd to things Adida me option to remove the first ook in the list Adida t ion to remove the b ook in the list Add a menu option to remate every look in the list 8:45 # READ ONLY - This is an older file for... Implement a linked list. Instructions Our last program was to maintain a list of books using a vector class crea assignment, you will be writing the linked list. Implement class Linkedli Nodes of a generic type. Nodes The Node class must be represented as a template. The Node class will require these private fields. Tdata: The data to hold in the Node Nodenext: A pointer to the next Node (if any) in the chain of No Node* prev: A pointer to the previous Node (if any) in the chain Linked List This class will require the following fields: Node* mHead: Points the first Node in the chain Node T m Tail: Points the last Node in the chain . int mSize: Keeps a count of the number of Nodes in the chain Your LinkedList class must also support the following public member fu LinkedList(): A default constructor sets both pointers to null and set Linkedlist const LinkedList&): A copy constructor that takes a Link performs a deep copy of the passed list into this list. . --Linked List): A destructor that performs pop front on the list while empty. operator=(const LinkedList&): LinkedList& An averloaded assignme deletes the current array and replaces it with deep copy of the passe sized const: int: Returns the size of the Linkedlist. push_back(const T): void: Creates a new Node and assigns it to the e Nodes while updating the size by 1. push front const T): void: Creates a new Node and assigns it to the fo Nodes while updating the size by 1. pop back(): T: Deletes the Node at the end of the list for throws an e possible. Decreases size by 1. Returns the deleted element. 8:46 READ ONLY - This is an older file for... TAIP VEILE. 1.UCICUS VICIUC OLVIC I I U possible). Decreases size by 1. Returns the deleted element. at(int) const: T: Returns the element stored at the specified index of-bounds (either for being negative or greater than/equal the size invalid _argument("Index out of bounds."); This will requin stdexcept library. This method should operate at O(1) for accessi element in a list and at O(n) for any element other than the first or front const: T: Returns the first element. hack const: T. Returns the last element. Return to the Books object. Return to your Books code. Find Books and remove the import staten and replace those with the local version of 'Linkedlist.hpp" that you m Add a menu option to add to the beginning of the list. Add a menu option to remove the first Book in the list Add a menu option to remove the last Book in the list Add a menu option to remove every Book in the list. Test your linked list application. Add a Book to the list 1,000 times. Add the list 1,000 times. Remove the first Book in the list. Remove the last B Verify that you have 1,998 Books in the list. After you verify that there are 1,998 Books in the list, clear the list using option. Verify that you have 0 Books in the list. What to Hand In Upload a zip file containing the following files to the drop box on D2L: LinkedList.hpp - the header file containing the entire class declar delinitions of the Linkedlist class. Normally, the definitions woul file, but class templates need to be handled differently in order for compiled properly by the C++ compiler. Node.hpp All files updated from the last homework assignment that have bee new linked list. Make sure your name, CSCI 3250, and Programming Assignment 4 comments in all of your files, Note: NO CREDIT will be given to programming assignments that Make sure you have compiled and tested your program before han