first commit
This commit is contained in:
131
Lab7/list.cpp
Normal file
131
Lab7/list.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
//## begin module.cm preserve=no
|
||||
|
||||
// %X% %Q% %Z% %W%
|
||||
|
||||
//## end module.cm
|
||||
|
||||
|
||||
|
||||
//## begin module.cp preserve=no
|
||||
|
||||
//## end module.cp
|
||||
|
||||
|
||||
|
||||
//## Module: List; Pseudo Package body
|
||||
|
||||
//## Subsystem: figures
|
||||
|
||||
//## Source file: H:\kurs\avC++\lab4\List.cpp
|
||||
|
||||
|
||||
|
||||
//## begin module.additionalIncludes preserve=no
|
||||
|
||||
//## end module.additionalIncludes
|
||||
|
||||
|
||||
|
||||
//## begin module.includes preserve=yes
|
||||
|
||||
//## end module.includes
|
||||
|
||||
|
||||
|
||||
// List
|
||||
|
||||
#include "List.h"
|
||||
|
||||
//## begin module.additionalDeclarations preserve=yes
|
||||
|
||||
//## end module.additionalDeclarations
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Parameterized Class List
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
|
||||
List<T>::List()
|
||||
|
||||
//## begin List::List%.hasinit preserve=no
|
||||
|
||||
//## end List::List%.hasinit
|
||||
|
||||
//## begin List::List%.initialization preserve=yes
|
||||
|
||||
//## end List::List%.initialization
|
||||
|
||||
{
|
||||
|
||||
//## begin List::List%.body preserve=yes
|
||||
|
||||
size = 0;
|
||||
|
||||
head = NULL;
|
||||
|
||||
current = NULL;
|
||||
|
||||
//## end List::List%.body
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
|
||||
List<T>::~List()
|
||||
|
||||
{
|
||||
|
||||
//## begin List::~List%.body preserve=yes
|
||||
|
||||
while(head != NULL){
|
||||
|
||||
current = head;
|
||||
|
||||
head = current->getNext();
|
||||
|
||||
delete current;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//## end List::~List%.body
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//## Other Operations (implementation)
|
||||
|
||||
template <class T>
|
||||
|
||||
T List<T>::getFirst ()
|
||||
|
||||
{
|
||||
|
||||
//## begin List::getFirst%937920679.body preserve=yes
|
||||
|
||||
current = head;
|
||||
|
||||
return head->getData();
|
||||
|
||||
//## end List::getFirst%937920679.body
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user