Changes

From CDOT Wiki
Jump to: navigation, search

Project A3 20141 - OOP344

951 bytes removed, 15:13, 2 April 2014
Class: IntList, Files [intlist.h, intlist.cpp], Test: 0: Cleaned up list.
=== Class: IntList, Files [intlist.h, intlist.cpp], Test: 0 ===
An IntList is the actual integer Integer linked list class. It manages a sequence of IntListNode. Because it needs to be able to set the next pointer on Uses IntListNode objects, this class '''may''' need to be as a friend of the IntListNode node class (this depends on how you implement these classes).
The exact specs follow:==== Recommended members ====* Pointer to head node in list* Current size (number of nodes) of list
==== Internal Variables Public Functions ====; IntListNode* _headsize: The Size getter. Const function. Does not receive parameters. Should return number of nodes in list.; head: 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'''. Should Receives an int parameter. The new node's value should be NULL when set to the received int.; 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.
==== Public Functions ====
; IntList(): Default constructor. Should set size to 0 and head to NULL.
; IntList(const IntList& src): Copy constructor. Should copy the list of nodes managed by '''src'''. This means that an entirely new list of nodes must be created, one node for each node managed by '''src''', and the value held by each of those nodes must '''equal''' the value held by the corresponding node managed by '''src'''. When this constructor is finished, the size of the current list should be the same as the size of src.<br/><br/>'''TIP:''' After initializing the current object to a '''safe and empty state''', don't forget that you may call '''any member function''' that the current list has!
; IntList& operator=(const IntList& src): Assignment operator. Should behave similarly to the copy constructor. '''ADDITIONALLY:''' Should do '''NOTHING''' in the case of '''self-assignment''' (ie IntList x; x = x;). If taking action, should clear the list of all nodes before creating new ones ('''make sure that you do NOT leak memory!'''). Should return a reference to the current object.
; int size() constConstructor: Size getterDoes not accept parameters. Returns the current value of the size memberInitializes list to safe empty state.; IntListNode* head() constStandard Assignment Operator: Head getterClears this list of all nodes. Returns Then, refills list with the current value same number of nodes as in the head pointersource list.; void push(int v): Adds a Value of 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.
== Part 2: Templated Linked List ==

Navigation menu