Switch to full style
For C/C++ coders discussions and solutions
Post a reply

Implementation of List

Sun May 25, 2008 5:14 pm

List Class implementation as data structure concept :

The header file :

Code:
#include<iostream.h>
typedef int ListElementType;

class List
{
public:
    List();
    void insert(const ListElementType & elem );
    bool first(ListElementType & elem);
    bool next(ListElementType & elem);

private:
    //implementation specific stuff here 
}; 


.cpp file
Code:
#include<iostream.h>
#include"ListADT.h"

List::List()
{
    numberOfElements=0;
    currentPostion=-1;
}
void List::insert(const ListElementType &elem)
{
      assert(numberOfElements<maxListSize);

      listArray[numberOfElements]=elem;

      numberOfElements++;
}
bool List::first(ListElementType & elem)
{
    if (numberOfElements==0)
        return false;
    else {
        currentPostion=0;
        elem=listArray[currentPostion];
        return true;
    }
}
bool List::next(ListElementType &elem)
{
    assert(currentPosition>=0)
        if(CurrentPosition>=numberOfElements-1)
            return false ;
        else {
            currentPostion--;

            elem=listArray[currentPostion];
            return true;
        }
}
 




Post a reply
  Related Posts  to : Implementation of List
 List C++ implementation     -  
 Linked List C++ Code Implementation     -  
 Implementation of association rules     -  
 merge sort implementation in C++     -  
 Associate Analyst- Implementation     -  
 serialization implementation in C++ - Part 2     -  
 Implementation of the DES & Triple DES in C++ or Java     -  
 wiener filter implementation     -  
 AES -S-BOX Linear Algorithm implementation-substitution box     -  
 Quicksort implementation C++ Code-Integers-Sorting     -  

Topic Tags

C++ Data Structures