Hakan Sözer

Yel Değirmenlerine Karşı Don Kişot Muyum?

Link list in c++ (for sorting methods)

March15
//List.h

#include <stdio.h>
#include <cstdlib>
#include <iostream>

using namespace std;

class List{
    private:
        struct Node
        {
            int data;

            Node *prev;
	    Node *next;
        }; 

    public:
        Node *FirstItem;
        Node *LastItem;
        int length;

        List();
        ~List();
        void deletion();
        void AddListItem(int value);
        void PrintList();
        void QuickSortList(Node *left, Node *right);
        void insertionSort();
        void radixSort();   

};

//-----------------------------------------------------------------//
//-----------------------------------------------------------------//

//List.cpp

#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <cmath>
#include "List.h"

List::List(){
    FirstItem = NULL;
    LastItem = NULL;
    length = 0;
}

List::~List(){
    deletion();
}

void List::deletion(){
    Node *delItem;
    Node *item = FirstItem;

    while (item != NULL){
        delItem = item;
        item = item->next;
        delete delItem;
    }

    FirstItem = NULL;
    LastItem = NULL;
}

void List::AddListItem(int value){
    Node *item = new Node;
    item->data = value;

    if (FirstItem == NULL){
        FirstItem = item;
        LastItem = item;
        item->next = NULL;
        item->prev = NULL;
    }
    else{
        LastItem->next = item;
        item->prev = LastItem;
        LastItem = item;
        item->next = NULL;
    }
    length++;
}

void List::PrintList(){
    Node *pItem = FirstItem;
    while (pItem != NULL){
        cout << pItem->data << endl;
        pItem = pItem->next;
    }
}

void List::QuickSortList(Node *left, Node *right){
    (click here to go quick sort method)
}

void List::insertionSort(){
    (click here to go insertion sort method)
}

void List::radixSort(){
    (click here to go radix sort method)
}

“Link list in c++ (for sorting methods)”

1 Yorum
  1. 14 July 2010 saat 9:23 am Asish diyor ki:

    Thankuuuuuuuuuu

E-posta gizli kalacak.

Website örneği

Yorumunuz: