okay they are big here they are:
list.h
//check for inclusion of data structures
#ifndef DATASTRUCTURE
#define DATASTRUCTURE
#include "list_data_structure.h"
#endif
//check for inclusion of debug levels
#ifndef LEVELS
#define LEVELS
#include "debug_levels.h"
#endif
//check for inclusion of errors
#ifndef ERRORS
#define ERRORS
#include "errors.h"
#endif
#define LIST
//class definition
class list//the list itself
{
public://accessor methods
list();//makes a head,tail, and blank node
~list();//destroys all nodex
void input(int input);
int return_no();
int i_return(int index);
int size();
int i_compare(int index, int value);
void move(signed int offset);//moves offset from n.cond
int l_compare(list l);//checks if 2 lists are identical
int l_compare(list l, int index);//checks if 2 index values hold same
int l_compare(list l, int lindex, int index);//checks if values are same
private:
node n;//connects all the data together
int no;//number of middle nodes
void new_node();//makes a new node
void to_root();//moves cond to root
void to_tail();//moves cond to tail
void back();//moves back in list
void forward();//moves forward in list
void seek(int index);//moves to given index
};
list.cpp
#include <iostream>
using namespace std;
#ifndef LIST
#define LIST
#include "list.h"
#endif
list::list()//default constructor
{
n.root=new data;//makes root node;
n.root->id=0;//sets root id
n.root->previous=0;//makes previous null
n.cond=n.root;//sets cond
n.cond->next=new data;//makes tail
n.tail=n.cond->next;//sets tail to address
n.tail->previous=n.root;//points previous to root
n.tail->id=1;//sets tail id
no=0;//sets no of internal nodes
n.tail->next=0;//sets next to null
}
void list::new_node()//adds a new node to the end of this list
{
n.cond=n.tail;//moves pointer to end
n.tail->next=new data;//adds new tail
n.tail=n.tail->next;//moves tail
n.tail->id=n.cond->id+1;//sets tail id
no++;//increases # of nodes
n.tail->next=0;//sets next pointer
n.tail->previous=n.cond;//sets previous pointer
}
list::~list()//erase all nodex
{
n.cond=n.root->next;
delete n.root;
while(n.cond->next->next!=0)//if next node is not tail
{
n.cond=n.cond->next;//moves node
delete n.cond->previous;//deletes last nopde
}
delete n.tail;//deletes the tail
n.root=0;//set pointers to null
n.tail=0;
n.cond=0;
}
void list::input(int input)
{
new_node();//adds a new node
n.cond->i_value=input;//inputs data into node
}
int list::return_no()//returns number of nodes
{
return no;
}
int list::i_return(int index)//returns integer value at given index
{
seek(index);
if(n.cond->id==index)//value match
{
return n.cond->i_value;
}
else
return 0;
}
void list::to_root()//moves cond to root
{
n.cond=n.root;
}
void list::to_tail()//moves cond to tail
{
n.cond=n.tail;
}
int list::size()
{
return 17*no+17*2;
}
int list::i_compare(int index, int value)//returns true if values match
{
seek(index);//moves to index
if(n.cond->i_value==value)//checks value
{
return 1;
}
else
{
return 0;
}
}
void list::seek(int index)
{
to_root();//moves to root
for(int x=1;x<=index;x++)
{
n.cond=n.cond->next;//move forward
}
}
void list::back()
{
if(n.cond->previous!=0)
n.cond=n.cond->previous;
}
void list::forward()
{
if(n.cond->next!=0)
n.cond=n.cond->next;
}
void list::move(int offset)
{
if(offset>0)//move up
{
for(int x=offset;x!=0;x--)
{
forward();
}
}
else
if(offset<0)//move down
{
for(int x=offset;x!=0;x++)
{
back();
}
}
else//stay
{
}
}
int list::l_compare(list l)
{
if(l.no==no)//same size
{
//move lists to root
l.to_root();
to_root();
l.forward();//move up
forward();//move up
//begin checking
for(int x=1;x<=no;x++)
{
if(l.n.cond->i_value==n.cond->i_value)//values are equal
{
l.forward();
forward();
}
else
{
return 0;
}
}
}
else
return 0;//not the same
return LIST_COMPARE_LOST_SCOPE;//error
}
int list::l_compare(list l,int index)
{
if(l.no>=index && no>=index)//if index exists in bot
{
l.to_root();//move to root;
to_root();
for(int x=1;x<=index;x++)
{
l.forward();
forward();
}//at value
if(l.n.cond->id==index && n.cond->id==index)//at index
{
//check if values match
if(n.cond->i_value==l.n.cond->i_value)
{
return 1;//match
}
else
{
return 0;//no match
}
}
else//not at index
{
return LIST_COMPARE_LOST_SCOPE;
}
}
}
int list::l_compare(list l,int lindex,int index)
{
if(l.no>=lindex && no>=index)//if in scope
{
l.to_root();//move to root;
to_root();
seek(index);//move to index
l.seek(lindex);
if(l.n.cond->id==lindex && n.cond->id==index)//at values
{
if(l.n.cond->i_value==n.cond->i_value)
{
return 1;
}
else
return 0;
}
else
{
return LIST_COMPARE_LOST_SCOPE;
}
return 0;
}
return 0;//out of scope
}
as you can see, in my data class ive included a value for alot of data types, which vastly increases memory consumption. but everytime i try to template it, even just define the constructor, i get about 2 errors, one on its signature, one on the opening bracket. please help
Your signature has been erased by a mod - please reduce it to 600x120