Click here to Skip to main content
15,499,573 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
XML
#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"
Posted
Comments
Sergey Alexandrovich Kryukov 13-Jun-12 18:30pm     CRLF
Not a question. What do you want to do? What's the problem? --SA
Sandeep Mewara 14-Jun-12 3:00am     CRLF
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific. Use the "Improve question" link to edit your question and provide better information.
Chris Losinger 15-Jun-12 11:10am    
you should do your own homework

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900