Changes

From CDOT Wiki
Jump to: navigation, search

Project A3 20141 - OOP344

33 bytes removed, 03:30, 23 March 2014
Class: IntList, Files [intlist.h, intlist.cpp], Test: 0: Finished List
; ListNode<T>* next() const: Next getter. Returns the internally held next pointer.
=== Class: IntListList<T>, Files File [intlistlist.h, intlist.cpp], Test: 0 1 ===An IntList is the actual integer A templated linked list class. It manages a sequence of IntListNodeSimilar to IntList. Because Similarly to IntList, because it needs to be able to set the next pointer on IntListNode ListNode<T> objects, this class '''may''' need to be a friend of the IntListNode ListNode<T> class (this depends on how you implement these classes).
The exact specs follow:
==== Internal Variables ====
; IntListNodeListNode<T>* _head: The head of the list. Should be NULL when the list is empty.
; int _size: The number of elements currently in the list.
==== Public Functions ====
; IntListList(): Default constructor. Should set size to 0 and head to NULL.; IntListList(const IntListList<T>& 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 can may call '''any member function''' that the current list has!; IntListList<T>& operator=(const IntListList<T>& src): Assignment operator. Should behave similarly to the copy constructor. '''ADDITIONALLY:''' Should do '''NOTHING''' in the case of '''self-assignment''' (ie IntList List<int> 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() const: Size getter. Returns the current value of the size member.
; IntListNodeListNode<T>* head() const: Head getter. Returns the current value of the head pointer.; void push(int const T& v): Adds a new node to the '''end of the list''' holding the value v. Should increment size.
; void pop(): Destroys the last node in the list. Should do '''NOTHING''' if the list is currently empty. Should decrement size if a node was destroyed. '''NOTE:''' If a node was destroyed, make sure that '''ANY POINTERS POINTING TO IT''', that your code has access to, are set to NULL.
; void clear(): Destroys all nodes in the list. Has no effect if the list is currently empty. When this function is finished, head should point to NULL and size should be 0.

Navigation menu