1
edit
Changes
→Class: List, Files [list.h], Test: 1: Updated templated list
=== Class: List<T>, Files [list.h], Test: 1 ===
A templated linked list class. Similar to IntList. Similarly to IntList, because it needs to be able to set the next pointer on Uses ListNode<T> objects, this class '''may''' need to be as a friend of the ListNode<T> node class (this depends on how you implement these classes).
==== Internal Variables Public Functions ====; ListNode<T>* _headConstructor: Does not accept parameters. Initializes list to safe empty state. ; size: Size getter. Const function. Does not receive parameters. Should return number of nodes in list.; head: The Head getter. Const function. Returns pointer to head node in list. ; push: Adds a new node to the '''end of the list'''. I'll say that again, '''END OF THE LIST'''. '''Important'''. Receives a const T reference. Should The new node's value should be NULL when set to the received reference.; pop: Destroys the '''last node in the list is empty'''. I'll say that again, '''LAST NODE IN THE LIST'''. Does not receive any arguments. Does not return anything.; int _sizeclear: The number of elements currently Removes all nodes in the list. Has no effect if the list is empty. Does not accept parameters. Does not return anything.
; int size() constStandard Assignment Operator: Size getterClears this list of all nodes. Returns Then, refills list with the current value same number of nodes as in the size member.; ListNode<T>* head() const: Head gettersource list. Returns the current value Value of the head pointer.; void push(const T& v): Adds a each new node to should equal the '''end value of the list''' holding the value v. Should increment size.; void pop(): Destroys the last corresponding node in the source list. Should do '''NOTHING''' if not alter object in the list is currently emptycase of self-assignment. Should decrement size if a node was destroyed. '''NOTE:''' If return a node was destroyed, make sure that '''ANY POINTERS POINTING TO IT''', that your code has access reference to, are set to NULLthe current object.; void clear()Copy Constructor: Destroys all nodes in the Initializes object to safe state then copies source list. Has no effect if the into current list is currently empty. When this function is finished, head should point Similar to NULL and size should be 0assignment operator.
== Submission ==
Please only submit '''ONCE YOUR CODE SUCCESSFULLY PASSES ALL TESTS!''' This includes the '''COMMON SENSE TEST''' which is the test that you perform '''yourself''' on your own code to ensure that it matches with what is required '''in the spec'''. Please see your instructor's specific instructions on how to submit.