#include "ListLinked.h" // ListNode member functions template <typename DataType> List<DataType>::ListNode::ListNode(const DataType& nodeData, ListNode* nextPtr) { this->dataItem = nodeData; this->next = nextPtr; } // List member functions template <typename DataType> List<DataType>::List(int ignored = 0) { s = cursor = 0; tempSize = ignored; dataItem = new DataType[ignored]; for(int i = 0;i<ignored;i++) dataItem[i] = NULL; } template <typename DataType> List<DataType>::List(const List& other) { tempSize = 0; dataItem = new DataType[0]; for(int i=0;i<0;i++) dataItem[i] = source.dataItem[i]; s = source.s; cursor = source.cursor; } template <typename DataType> List<DataType>& List<DataType>::operator=(const List& other) { this -> clear(); for(int i=0;i<tempSize;i++) dataItem[i] = source.dataItem[i]; } template <typename DataType> List<DataType>::~List() { delete [] dataItem; } template <typename DataType> void List<DataType>::insert(const DataType& newDataItem) throw (logic_error) { if(s == 0) dataItem[cursor] = newDataItem; else { dataItem[cursor+1] = newDataItem; } s++; cursor = s - 1; } template <typename DataType> void List<DataType>::remove() throw (logic_error) { dataItem[cursor + 1] = NULL; s--; if(dataItem[cursor + 1] == NULL) cursor = 0; else cursor++; } template <typename DataType> void List<DataType>::replace(const DataType& newDataItem) throw (logic_error) { dataItem[cursor] = newDataItem; } template <typename DataType> void List<DataType>::clear() { for(int i=0;i<s;i++) dataItem[i] = NULL; s = cursor = 0; } template <typename DataType> bool List<DataType>::isEmpty() const { return false; } template <typename DataType> bool List<DataType>::isFull() const { return false; } template <typename DataType> void List<DataType>::gotoBeginning() throw (std::logic_error) { cursor = 0; } template <typename DataType> void List<DataType>::gotoEnd() throw (logic_error) { cursor = s - 1; } template <typename DataType> bool List<DataType>::gotoNext() throw (logic_error) { return false; } template <typename DataType> bool List<DataType>::gotoPrior() throw (logic_error) { return false; } template <typename DataType> DataType List<DataType>::getCursor() const throw (logic_error) { DataType t; return t; } template <typename DataType> void List<DataType>::moveToBeginning () throw (logic_error) { } template <typename DataType> void List<DataType>::insertBefore(const DataType& newDataItem) throw (logic_error) { } #include "show5.cpp"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)